Class: RelatonBib::Classification

Inherits:
Object
  • Object
show all
Defined in:
lib/relaton_bib/classification.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type: nil, value:) ⇒ Classification

Returns a new instance of Classification.

Parameters:

  • type (String, NilClass) (defaults to: nil)
  • value (String)


11
12
13
14
# File 'lib/relaton_bib/classification.rb', line 11

def initialize(type: nil, value:)
  @type  = type
  @value = value
end

Instance Attribute Details

#typeString, NilClass (readonly)

Returns:

  • (String, NilClass)


4
5
6
# File 'lib/relaton_bib/classification.rb', line 4

def type
  @type
end

#valueString (readonly)

Returns:

  • (String)


7
8
9
# File 'lib/relaton_bib/classification.rb', line 7

def value
  @value
end

Instance Method Details

#to_hashHash

Returns:

  • (Hash)


23
24
25
26
27
# File 'lib/relaton_bib/classification.rb', line 23

def to_hash
  hash = { "value" => value }
  hash["type"] = type if type
  hash
end

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


17
18
19
20
# File 'lib/relaton_bib/classification.rb', line 17

def to_xml(builder)
  xml = builder.classification value
  xml[:type] = type if type
end