class RubyJisho::Sense

Wrapper for sense hashes from the Jisho API

Attributes

response[R]

Public Class Methods

new(response_hash) click to toggle source
# File lib/ruby_jisho/sense.rb, line 8
def initialize(response_hash)
  @response = response_hash
end

Public Instance Methods

keys() click to toggle source
# File lib/ruby_jisho/sense.rb, line 21
def keys
  response.keys
end
method_missing(sym, *args, &block) click to toggle source
Calls superclass method
# File lib/ruby_jisho/sense.rb, line 25
def method_missing(sym, *args, &block)
  if keys.include?(sym)
    response.fetch(sym)
  else
    super
  end
end
parts_of_speech() click to toggle source
# File lib/ruby_jisho/sense.rb, line 12
def parts_of_speech
  response.fetch(:parts_of_speech, [''])
          .map { |p| p.downcase.to_sym }
end
respond_to_missing?(method_name, include_private = false) click to toggle source
Calls superclass method
# File lib/ruby_jisho/sense.rb, line 33
def respond_to_missing?(method_name, include_private = false)
  keys.include?(method_name) || super
end
to_h() click to toggle source
# File lib/ruby_jisho/sense.rb, line 17
def to_h
  response
end