Class: Ting::Writer

Inherits:
Object
  • Object
show all
Includes:
Procable
Defined in:
lib/ting/writer.rb

Instance Method Summary collapse

Methods included from Procable

#memoize, #to_proc

Constructor Details

#initialize(conv, tone) ⇒ Writer

Returns a new instance of Writer.



5
6
7
8
# File 'lib/ting/writer.rb', line 5

def initialize(conv, tone)
  @conv = conv.to_s
  @tone = Tones.const_get Ting.camelize(tone.to_s)
end

Instance Method Details

#generate(syll) ⇒ Object Also known as: <<, unparse, call



10
11
12
13
14
15
16
17
# File 'lib/ting/writer.rb', line 10

def generate(syll)
  Array(syll).map do |s|
    syllable = Conversions.unparse(@conv, s)
    str = @tone.add_tone(syllable, s.tone)
    str.capitalize! if s.capitalized?
    str
  end.join(' ')
end