Class: Phonology::OrthographyTranslator

Inherits:
Object
  • Object
show all
Includes:
OrthographyTranslatorDSL
Defined in:
lib/phonology/orthography.rb

Instance Attribute Summary collapse

Attributes included from OrthographyTranslatorDSL

#anticipation, #last_sound

Instance Method Summary collapse

Methods included from OrthographyTranslatorDSL

#anticipate, #between, #context, #curr_char, #final?, #follows, #get, #initial?, #method_missing, #next_char, #offset, #precedes, #prev_char

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Phonology::OrthographyTranslatorDSL

Instance Attribute Details

#rulesObject

Returns the value of attribute rules.



90
91
92
# File 'lib/phonology/orthography.rb', line 90

def rules
  @rules
end

#scannerObject

Returns the value of attribute scanner.



90
91
92
# File 'lib/phonology/orthography.rb', line 90

def scanner
  @scanner
end

#soundsObject

Returns the value of attribute sounds.



90
91
92
# File 'lib/phonology/orthography.rb', line 90

def sounds
  @sounds
end

#stringObject

Returns the value of attribute string.



90
91
92
# File 'lib/phonology/orthography.rb', line 90

def string
  @string
end

Instance Method Details

#set_rules(&block) ⇒ Object



110
111
112
# File 'lib/phonology/orthography.rb', line 110

def set_rules(&block)
  @rules = block
end

#translate(string) ⇒ Object

Translate orthorgraphy to IPA



95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/phonology/orthography.rb', line 95

def translate(string)
  @string = string
  @max = array.length
  SoundSequence.new(array.each_index.map do |index|
    @index = index
    instance_eval(&@rules)
  end.flatten.compact)
ensure
  @max = 0
  @string = nil
  @array = nil
  @index = nil
  @last_sound = nil
end