class GimmeWikidata::Claim

Models a Claim on Wikidata, which consists of a Property and a value

Note that the value can be of any type (example: a number, a date), and is often another Item on Wikidata.

For more details, please see: www.wikidata.org/wiki/Wikidata:Glossary#Claims_and_statements

Attributes

property[R]

The Property that the Claim is about

value[R]

The value that the Property is claimed to have

value_type[R]

The type of value. Current types:

  • item

  • property

  • wikidata_time

  • external_id

  • media

  • text

  • url

  • gps_coordinates

  • quantity

Public Class Methods

new(property = nil, value = nil, value_type = nil) click to toggle source
# File lib/gimme_wikidata/claim.rb, line 32
def initialize(property = nil, value = nil, value_type = nil)
  @property = property
  @value = value
  @value_type = value_type
end

Public Instance Methods

print(colour = :blue) click to toggle source

Prints a pretty version of the Claim to the console

simplify() click to toggle source

Returns a simple hash form of the claim.

Example: {sex_or_gender: “Male”}

# File lib/gimme_wikidata/claim.rb, line 42
def simplify
  property = @property.label
  value = simplify_value
  return {property: property, value: value}
end
simplify_value() click to toggle source

Simplifies the value

TODO: DOCUMENT THIS FUNCTION BETTER

# File lib/gimme_wikidata/claim.rb, line 52
def simplify_value
  case @value_type
  when :item, :property
    return "#{@value.label} (#{@value.id})"
  when :carbon_date
    return @value.to_s
  when :external_id, :media, :text, :url, :gps_coordinates, :quantity
    return @value
  else
    return nil # TODO: Consider throwing an exception here
  end
end