Class: Wikidatum::DataType::WikibaseString

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

Overview

The String type JSON looks like this:

{
  "property": {
    "id": "P143",
    "data-type": "string"
  },
  "value": {
    "type": "value",
    "content": "foo"
  }
}

Direct Known Subclasses

CommonsMedia, ExternalId, WikibaseUrl

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string:) ⇒ void

Parameters:

  • string (String)


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

def initialize(string:)
  @string = string
end

Instance Attribute Details

#stringString (readonly)

Returns the value for the string.

Returns:

  • (String)

    the value for the string.



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

def string
  @string
end

Class Method Details

.symbolized_nameSymbol

Returns:

  • (Symbol)


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

def self.symbolized_name
  :string
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_string.rb', line 47

def humanized
  @string
end

#to_hHash

Returns:

  • (Hash)


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

def to_h
  {
    string: @string
  }
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_string.rb', line 39

def wikibase_type
  'string'
end