Class: Tracinho::Word
- Inherits:
-
Object
- Object
- Tracinho::Word
- Defined in:
- lib/tracinho/word.rb
Overview
Word is the class that represents a word (duh!). It includes some methods to quickly get the complement word or the classification.
Example:
word = Tracinho::Word.new('comeste')
word.hyphenated?
# => false
word.complement
# => "comes-te"
word.grammar_class
# => "Segunda pessoa do singular do pretérito perfeito do indicativo do verbo comer."
Instance Method Summary collapse
-
#complement ⇒ Object
Returns the complement of the word.
- #grammar_class ⇒ Object
-
#hyphenated? ⇒ Boolean
Returns true if the word as a hyphen (the ‘-’ character) or false otherwise.
-
#initialize(text) ⇒ Word
constructor
A new instance of Word.
- #to_s ⇒ Object
Constructor Details
#initialize(text) ⇒ Word
Returns a new instance of Word.
20 21 22 |
# File 'lib/tracinho/word.rb', line 20 def initialize(text) @text = text end |
Instance Method Details
#complement ⇒ Object
Returns the complement of the word.
30 31 32 |
# File 'lib/tracinho/word.rb', line 30 def complement ComplementBuilder.new(self).build end |
#grammar_class ⇒ Object
34 35 36 |
# File 'lib/tracinho/word.rb', line 34 def grammar_class WordClassifier.new(self).full_classification end |
#hyphenated? ⇒ Boolean
Returns true if the word as a hyphen (the ‘-’ character) or false otherwise.
25 26 27 |
# File 'lib/tracinho/word.rb', line 25 def hyphenated? @text.include?('-') end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/tracinho/word.rb', line 38 def to_s @text end |