Class: Dict::Result

Inherits:
Object
  • Object
show all
Defined in:
lib/dict/result.rb

Overview

Objects of this class are returned by methods retrieving translations from Web dictionaries.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(term) ⇒ Result

Returns a new instance of Result.



7
8
9
10
11
# File 'lib/dict/result.rb', line 7

def initialize(term)
  @term = term
  @translations = {}
  @examples = {}
end

Instance Attribute Details

#examplesObject (readonly)

Returns the value of attribute examples.



5
6
7
# File 'lib/dict/result.rb', line 5

def examples
  @examples
end

#termObject (readonly)

Returns the value of attribute term.



5
6
7
# File 'lib/dict/result.rb', line 5

def term
  @term
end

#translationsObject (readonly)

Returns the value of attribute translations.



5
6
7
# File 'lib/dict/result.rb', line 5

def translations
  @translations
end

Instance Method Details

#add_example(term, example) ⇒ Object



17
18
19
# File 'lib/dict/result.rb', line 17

def add_example(term, example)
  add_result(@examples, term, example)
end

#add_translation(term, translation) ⇒ Object



13
14
15
# File 'lib/dict/result.rb', line 13

def add_translation(term, translation)
  add_result(@translations, term, translation)
end

#each_translationObject



21
22
23
24
25
# File 'lib/dict/result.rb', line 21

def each_translation
  @translations.each_pair do |term,translation|
    yield term, translation
  end
end