Class: Swatchman::Swatch
- Inherits:
-
Object
- Object
- Swatchman::Swatch
- Defined in:
- lib/swatchman/swatch.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
-
#frequency ⇒ Object
readonly
Returns the value of attribute frequency.
Instance Method Summary collapse
-
#initialize(color, frequency) ⇒ Swatch
constructor
A new instance of Swatch.
- #percentage(total) ⇒ Object
Constructor Details
#initialize(color, frequency) ⇒ Swatch
Returns a new instance of Swatch.
5 6 7 8 |
# File 'lib/swatchman/swatch.rb', line 5 def initialize(color, frequency) @color = color.downcase @frequency = frequency end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
3 4 5 |
# File 'lib/swatchman/swatch.rb', line 3 def color @color end |
#frequency ⇒ Object (readonly)
Returns the value of attribute frequency.
3 4 5 |
# File 'lib/swatchman/swatch.rb', line 3 def frequency @frequency end |
Instance Method Details
#percentage(total) ⇒ Object
10 11 12 |
# File 'lib/swatchman/swatch.rb', line 10 def percentage(total) (frequency / total) * 100 end |