class Dictation::Word

Attributes

translation[RW]
value[RW]

Public Class Methods

json_create(object) click to toggle source
# File lib/dictation/word.rb, line 42
def json_create(object)
  new(*object['data'])
end
new(value, translation = nil) click to toggle source
# File lib/dictation/word.rb, line 9
def initialize(value, translation = nil)
  @value = value
  @translation = translation
end

Public Instance Methods

orthography() click to toggle source
# File lib/dictation/word.rb, line 14
def orthography
  decompose(@value)
end
to_json(*args) click to toggle source
# File lib/dictation/word.rb, line 34
def to_json(*args)
  {
    'json_class' => self.class.name,
    'data'       => [ @value, @translation ]
  }.to_json(*args)
end

Private Instance Methods

decompose(word) click to toggle source
# File lib/dictation/word.rb, line 18
def decompose(word)
  word.split(//).map! do |x|
    normalize(x)
  end
end
normalize(letter) click to toggle source
# File lib/dictation/word.rb, line 24
def normalize(letter)
  letter = letter.downcase.chomp
  case letter
  when 'ß'
    'ss'
  else
    letter
  end
end