Class: Tracinho::Word

Inherits:
Object
  • Object
show all
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

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

#complementObject

Returns the complement of the word.



30
31
32
# File 'lib/tracinho/word.rb', line 30

def complement
  ComplementBuilder.new(self).build
end

#grammar_classObject



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.

Returns:

  • (Boolean)


25
26
27
# File 'lib/tracinho/word.rb', line 25

def hyphenated?
  @text.include?('-')
end

#to_sObject



38
39
40
# File 'lib/tracinho/word.rb', line 38

def to_s
  @text
end