Class: Wikidatum::Statement

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id:, property_id:, data_type:, data_value:, qualifiers:, references:, rank: 'normal') ⇒ Statement

Returns a new instance of Statement.

Parameters:



34
35
36
37
38
39
40
41
42
# File 'lib/wikidatum/statement.rb', line 34

def initialize(id:, property_id:, data_type:, data_value:, qualifiers:, references:, rank: 'normal')
  @id = id
  @property_id = property_id
  @data_type = data_type
  @data_value = data_value
  @qualifiers = qualifiers
  @references = references
  @rank = rank
end

Instance Attribute Details

#data_typeString

Returns:

  • (String)


11
12
13
# File 'lib/wikidatum/statement.rb', line 11

def data_type
  @data_type
end

#idString (readonly)

Returns:

  • (String)


5
6
7
# File 'lib/wikidatum/statement.rb', line 5

def id
  @id
end

#property_idString

Returns property ID, in the format of ‘P123’.

Returns:

  • (String)

    property ID, in the format of ‘P123’.



8
9
10
# File 'lib/wikidatum/statement.rb', line 8

def property_id
  @property_id
end

#qualifiersArray<Wikidatum::Qualifier>

Returns:



17
18
19
# File 'lib/wikidatum/statement.rb', line 17

def qualifiers
  @qualifiers
end

#rankString

Returns the rank of the given statement. Can have the values “preferred”, “normal”, or “deprecated”. Defaults to “normal”.

Returns:

  • (String)

    the rank of the given statement. Can have the values “preferred”, “normal”, or “deprecated”. Defaults to “normal”.



24
25
26
# File 'lib/wikidatum/statement.rb', line 24

def rank
  @rank
end

#referencesArray<Wikidatum::Reference>

Returns:



20
21
22
# File 'lib/wikidatum/statement.rb', line 20

def references
  @references
end

Instance Method Details

#to_hHash

Returns:

  • (Hash)


45
46
47
48
49
50
51
52
53
54
55
# File 'lib/wikidatum/statement.rb', line 45

def to_h
  {
    id: @id,
    property_id: @property_id,
    data_type: @data_type,
    data_value: @data_value.to_h,
    qualifiers: @qualifiers.map(&:to_h),
    references: @references.map(&:to_h),
    rank: @rank
  }
end