Sha256: 3d2888b320d04c75c33793b9c40f9e8f5f522b1c74e0aea4b2745bc150bef723
Contents?: true
Size: 810 Bytes
Versions: 3
Compression:
Stored size: 810 Bytes
Contents
require "synonymous/definition" require "synonymous/headword" module Synonymous class Entry def initialize(data) @data = data end def functional_label # https://dictionaryapi.com/products/json#sec-2.fl @data.fetch("fl") end def headword # https://dictionaryapi.com/products/json#sec-2.hwi Headword.new(@data.fetch("hwi")) end def senses definition.senses end 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 def definitions # https://dictionaryapi.com/products/json#sec-2.def @data.fetch("def").map { |data| Definition.new(data) } end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
synonymous-0.3.0 | lib/synonymous/entry.rb |
synonymous-0.2.0 | lib/synonymous/entry.rb |
synonymous-0.1.0 | lib/synonymous/entry.rb |