Class: WhatIMean::Word
- Inherits:
-
Object
- Object
- WhatIMean::Word
- Defined in:
- lib/whatimean/word.rb
Instance Attribute Summary collapse
-
#hits ⇒ Object
Returns the value of attribute hits.
-
#name ⇒ Object
Returns the value of attribute name.
-
#rate ⇒ Object
Returns the value of attribute rate.
Instance Method Summary collapse
-
#calculate_rate(total) ⇒ Word
Calculate.
-
#initialize(attributes) ⇒ Word
constructor
Instatiate a new Word with following attributes:.
Constructor Details
#initialize(attributes) ⇒ Word
Instatiate a new Word with following attributes:
12 13 14 15 16 17 18 |
# File 'lib/whatimean/word.rb', line 12 def initialize(attributes) attributes.each do |key, value| send("#{key}=", value) end self end |
Instance Attribute Details
#hits ⇒ Object
Returns the value of attribute hits.
4 5 6 |
# File 'lib/whatimean/word.rb', line 4 def hits @hits end |
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/whatimean/word.rb', line 4 def name @name end |
#rate ⇒ Object
Returns the value of attribute rate.
4 5 6 |
# File 'lib/whatimean/word.rb', line 4 def rate @rate end |
Instance Method Details
#calculate_rate(total) ⇒ Word
Calculate
23 24 25 26 |
# File 'lib/whatimean/word.rb', line 23 def calculate_rate(total) self.rate = hits / total.to_f self end |