Class: Agenda::Word
- Inherits:
-
Object
- Object
- Agenda::Word
- Defined in:
- lib/agenda/word.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
Returns the value of attribute count.
-
#tags ⇒ Object
Returns the value of attribute tags.
-
#word ⇒ Object
Returns the value of attribute word.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #has_tag?(tag) ⇒ Boolean
-
#initialize(the_word) ⇒ Word
constructor
A new instance of Word.
- #to_s ⇒ Object
Constructor Details
#initialize(the_word) ⇒ Word
Returns a new instance of Word.
5 6 7 |
# File 'lib/agenda/word.rb', line 5 def initialize(the_word) @word = the_word.downcase; @count = 0; = [] end |
Instance Attribute Details
#count ⇒ Object
Returns the value of attribute count.
3 4 5 |
# File 'lib/agenda/word.rb', line 3 def count @count end |
#tags ⇒ Object
Returns the value of attribute tags.
3 4 5 |
# File 'lib/agenda/word.rb', line 3 def end |
#word ⇒ Object
Returns the value of attribute word.
3 4 5 |
# File 'lib/agenda/word.rb', line 3 def word @word end |
Instance Method Details
#==(other) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/agenda/word.rb', line 23 def ==(other) if other.is_a? Agenda::Word return other.word == @word else other.is_a? String return other == @word end end |
#eql?(other) ⇒ Boolean
19 20 21 |
# File 'lib/agenda/word.rb', line 19 def eql?(other) other.word == @word end |
#has_tag?(tag) ⇒ Boolean
15 16 17 |
# File 'lib/agenda/word.rb', line 15 def has_tag?(tag) .include? tag end |
#to_s ⇒ Object
9 10 11 12 13 |
# File 'lib/agenda/word.rb', line 9 def to_s s = "#{@word}: #{@count}" s += " (" + .join(", ") + ")" unless .empty? s end |