Class: Wikidatum::DataType::WikibaseItem

Inherits:
Object
  • Object
show all
Defined in:
lib/wikidatum/data_type/wikibase_item.rb

Overview

The Wikibase Item type JSON looks like this:

{
  "property": {
    "id": "P963",
    "data-type": "wikibase-item"
  },
  "value": {
    "type": "value",
    "content": "Q524026"
  }
}

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:) ⇒ void

Parameters:

  • id (String)


25
26
27
# File 'lib/wikidatum/data_type/wikibase_item.rb', line 25

def initialize(id:)
  @id = id
end

Instance Attribute Details

#idString (readonly)

Returns in the format “Q123”.

Returns:

  • (String)

    in the format “Q123”.



21
22
23
# File 'lib/wikidatum/data_type/wikibase_item.rb', line 21

def id
  @id
end

Class Method Details

.symbolized_nameSymbol

Returns:

  • (Symbol)


52
53
54
# File 'lib/wikidatum/data_type/wikibase_item.rb', line 52

def self.symbolized_name
  :wikibase_item
end

Instance Method Details

#humanizedString

The content of the data value object. Use this to get a more sensible representation of the statement’s contents.

Returns:

  • (String)


47
48
49
# File 'lib/wikidatum/data_type/wikibase_item.rb', line 47

def humanized
  @id
end

#to_hHash

Returns:

  • (Hash)


30
31
32
33
34
# File 'lib/wikidatum/data_type/wikibase_item.rb', line 30

def to_h
  {
    id: @id
  }
end

#wikibase_typeString

The “type” value used by Wikibase, for use when creating/updating statements.

Returns:

  • (String)


39
40
41
# File 'lib/wikidatum/data_type/wikibase_item.rb', line 39

def wikibase_type
  'wikibase-item'
end