Class: Tracinho::ComplementBuilder
- Inherits:
-
Object
- Object
- Tracinho::ComplementBuilder
- Defined in:
- lib/tracinho/complement_builder.rb
Overview
ComplementBuilder converts words with dash in the version without it and vice-versa.
Instance Method Summary collapse
-
#build ⇒ Object
Builds the complementary word.
-
#initialize(word) ⇒ ComplementBuilder
constructor
A new instance of ComplementBuilder.
Constructor Details
#initialize(word) ⇒ ComplementBuilder
Returns a new instance of ComplementBuilder.
6 7 8 |
# File 'lib/tracinho/complement_builder.rb', line 6 def initialize(word) @word = word end |
Instance Method Details
#build ⇒ Object
Builds the complementary word.
ComplementBuilder.new(Word.new('fizeste')).build
# => #<Tracinho::Word:0x007f8a9b0ba928 @text="fize-te">
ComplementBuilder.new(Word.new('passa-mos')).build
# => #<Tracinho::Word:0x007f8a9b10f270 @text="passamos">
17 18 19 20 21 |
# File 'lib/tracinho/complement_builder.rb', line 17 def build text = @word.hyphenated? ? remove_dash(@word.to_s) : add_dash(@word.to_s) Word.new(text) end |