Class: Swatchman::Swatch

Inherits:
Object
  • Object
show all
Defined in:
lib/swatchman/swatch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#colorObject (readonly)

Returns the value of attribute color.



3
4
5
# File 'lib/swatchman/swatch.rb', line 3

def color
  @color
end

#frequencyObject (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