Sha256: 712ac98496e89297dc3db1e381a1da0912825c245b14d62c8b03fc3fe31c05dc

Contents?: true

Size: 600 Bytes

Versions: 1

Compression:

Stored size: 600 Bytes

Contents

module Wordnik
  class Word
    attr_reader :word

    def initialize(word, eager = false)
      @word = word.dup.freeze
      load_all if eager
    end

    def wordnik_id
      @wordnik_id ||= Wordnik.instance.lookup(word)['id']
    end

    def definitions
      @definitions ||= Wordnik.instance.define(word)
    end

    def frequencies
      @frequencies ||= Wordnik.instance.frequency(word)
    end

    def examples
      @examples ||= Wordnik.instance.examples(word)
    end

    private

    def load_all
      wordnik_id
      definitions
      frequencies
      examples
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
wordnik-0.1.0 lib/wordnik/word.rb