Class: Dict::Result
- Inherits:
-
Object
- Object
- Dict::Result
- Defined in:
- lib/dict/result.rb
Overview
Objects of this class are returned by methods retrieving translations from Web dictionaries.
Instance Attribute Summary collapse
-
#examples ⇒ Object
readonly
Returns the value of attribute examples.
-
#term ⇒ Object
readonly
Returns the value of attribute term.
-
#translations ⇒ Object
readonly
Returns the value of attribute translations.
Instance Method Summary collapse
- #add_example(term, example) ⇒ Object
- #add_translation(term, translation) ⇒ Object
- #each_translation ⇒ Object
-
#initialize(term) ⇒ Result
constructor
A new instance of Result.
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
#examples ⇒ Object (readonly)
Returns the value of attribute examples.
5 6 7 |
# File 'lib/dict/result.rb', line 5 def examples @examples end |
#term ⇒ Object (readonly)
Returns the value of attribute term.
5 6 7 |
# File 'lib/dict/result.rb', line 5 def term @term end |
#translations ⇒ Object (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_translation ⇒ Object
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 |