Sha256: a9646c3268830781f3f5f26b2f850a5c2025c2afae37ff2ee396d6b6c2810ba5
Contents?: true
Size: 634 Bytes
Versions: 1
Compression:
Stored size: 634 Bytes
Contents
module Wikidata class Response extend Forwardable def_delegators :results, :size def initialize raw @raw = raw end def results return [] if empty? @_results ||= raw_results.map{|r| Wikidata::Item.new(r) } end def empty? @_empty ||= (@raw.body['entities'].nil? || @raw.body['entities'].is_a?(Array) && @raw.body['entities'].empty?) end def inspect "<#{self.class} results: #{results.inspect}>" end protected def raw_results return [] if empty? @raw.body['entities'].values.reject{|r| r['missing'] } end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
wikidata-client-0.0.5 | lib/wikidata/response.rb |