class Synonymous::Entry

Public Class Methods

new(data) click to toggle source
# File lib/synonymous/entry.rb, line 6
def initialize(data)
  @data = data
end

Public Instance Methods

definition() click to toggle source
# File lib/synonymous/entry.rb, line 24
def definition
  case definitions.count
  when 1 then definitions[0]
  when 0 then raise Synonymous::Error, "No definitions"
  else raise Synonymous::Error, "Multiple definitions"
  end
end
definitions() click to toggle source
# File lib/synonymous/entry.rb, line 32
def definitions
  # https://dictionaryapi.com/products/json#sec-2.def
  @data.fetch("def").map { |data| Definition.new(data) }
end
functional_label() click to toggle source
# File lib/synonymous/entry.rb, line 10
def functional_label
  # https://dictionaryapi.com/products/json#sec-2.fl
  @data.fetch("fl")
end
headword() click to toggle source
# File lib/synonymous/entry.rb, line 15
def headword
  # https://dictionaryapi.com/products/json#sec-2.hwi
  Headword.new(@data.fetch("hwi"))
end
senses() click to toggle source
# File lib/synonymous/entry.rb, line 20
def senses
  definition.senses
end