Class: Wikidata::DataValues::CommonsMedia

Inherits:
Value show all
Defined in:
lib/wikidata/datavalues/commons_media.rb

Instance Attribute Summary

Attributes inherited from HashedObject

#data_hash

Instance Method Summary collapse

Methods inherited from Value

#resolved

Methods inherited from HashedObject

#initialize, #method_missing

Constructor Details

This class inherits a constructor from Wikidata::HashedObject

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Wikidata::HashedObject

Instance Method Details

#resolve!Object



9
10
11
12
13
14
# File 'lib/wikidata/datavalues/commons_media.rb', line 9

def resolve!
  query = {image: data_hash.imagename, thumbwidth: 150}
  puts "Getting: #{query}".yellow if Wikidata.verbose?
  r = HTTParty.get('http://tools.wmflabs.org/magnus-toolserver/commonsapi.php', {query: query})
  @data_hash = Hashie::Mash.new(r['response'].merge({imagename: data_hash.imagename}))
end

#to_sObject



5
6
7
# File 'lib/wikidata/datavalues/commons_media.rb', line 5

def to_s
  data_hash.imagename
end