Class: Samantha::Color
- Inherits:
-
Object
- Object
- Samantha::Color
- Defined in:
- lib/colors.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#hex ⇒ Object
Returns the value of attribute hex.
Instance Method Summary collapse
-
#initialize(hex) ⇒ Color
constructor
A new instance of Color.
- #tally ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(hex) ⇒ Color
Returns a new instance of Color.
6 7 8 9 |
# File 'lib/colors.rb', line 6 def initialize(hex) @hex = hex @count = 1 end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
4 5 6 |
# File 'lib/colors.rb', line 4 def count @count end |
#hex ⇒ Object
Returns the value of attribute hex.
4 5 6 |
# File 'lib/colors.rb', line 4 def hex @hex end |
Instance Method Details
#tally ⇒ Object
11 12 13 |
# File 'lib/colors.rb', line 11 def tally @count += 1 end |
#to_s ⇒ Object
15 16 17 |
# File 'lib/colors.rb', line 15 def to_s "#{Paint['●', @hex, nil]} ##{@hex.ljust(6)} #{@count.to_s}" end |