Class: Vocabulary::Word

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(summary) ⇒ Word

Returns a new instance of Word.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
# File 'lib/vocabulary.rb', line 8

def initialize summary
  raise ArgumentError, "Bad summary" unless summary
  @part_of_speech = summary["primaries"][0]["entries"][0]["labels"][0]["text"]
  
  @meanings = []
  summary["primaries"][0]["entries"][0]["entries"].each do |meaning|
    @meanings << meaning["terms"][0]["text"]
  end
end

Instance Attribute Details

#meaningsObject

Returns the value of attribute meanings.



6
7
8
# File 'lib/vocabulary.rb', line 6

def meanings
  @meanings
end

#part_of_speechObject

Returns the value of attribute part_of_speech.



6
7
8
# File 'lib/vocabulary.rb', line 6

def part_of_speech
  @part_of_speech
end