Guest User

Untitled

a guest
Jul 15th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.31 KB | None | 0 0
  1. class VU
  2. include Comparable
  3. attr :volume
  4. def initialize(volume) # 0..9
  5. @volume = volume
  6. end
  7. def inspect
  8. '#' * @volume
  9. end
  10. # Support for ranges
  11. def <=>(other)
  12. self.volume <=> other.volume
  13. end
  14. def succ
  15. raise(IndexError, "Volume too big") if @volume >= 9
  16. VU.new(@volume.succ)
  17. end
  18. end
Add Comment
Please, Sign In to add comment