Class: Dictation::Word

Inherits:
Object
  • Object
show all
Defined in:
lib/dictation/word.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, translation = nil) ⇒ Word

Returns a new instance of Word.



9
10
11
12
# File 'lib/dictation/word.rb', line 9

def initialize(value, translation = nil)
  @value = value
  @translation = translation
end

Instance Attribute Details

#translationObject

Returns the value of attribute translation.



7
8
9
# File 'lib/dictation/word.rb', line 7

def translation
  @translation
end

#valueObject

Returns the value of attribute value.



7
8
9
# File 'lib/dictation/word.rb', line 7

def value
  @value
end

Class Method Details

.json_create(object) ⇒ Object



42
43
44
# File 'lib/dictation/word.rb', line 42

def json_create(object)
  new(*object['data'])
end

Instance Method Details

#orthographyObject



14
15
16
# File 'lib/dictation/word.rb', line 14

def orthography
  decompose(@value)
end

#to_json(*args) ⇒ Object



34
35
36
37
38
39
# File 'lib/dictation/word.rb', line 34

def to_json(*args)
  {
    'json_class' => self.class.name,
    'data'       => [ @value, @translation ]
  }.to_json(*args)
end