Class: RelatonBib::BibliographicSize::Value

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type:, value:) ⇒ Value

Initialize a BibliographicSize::Value object.

Parameters:

  • type (String)

    the type of the size

  • value (String)

    size value



63
64
65
66
# File 'lib/relaton_bib/bibliographic_size.rb', line 63

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

Instance Attribute Details

#typeString (readonly)

Returns:

  • (String)


55
56
57
# File 'lib/relaton_bib/bibliographic_size.rb', line 55

def type
  @type
end

#valueString (readonly)

Returns:

  • (String)


55
56
57
# File 'lib/relaton_bib/bibliographic_size.rb', line 55

def value
  @value
end

Instance Method Details

#to_asciibib(prefix, size) ⇒ String

Render BibliographicSize::Value object to AsciiBib.

Parameters:

  • prefix (String)

    prefix for the size

  • size (Integer)

    size of the array

Returns:

  • (String)

    AsciiBib string



94
95
96
97
98
99
100
# File 'lib/relaton_bib/bibliographic_size.rb', line 94

def to_asciibib(prefix, size)
  pref = prefix.empty? ? "" : "#{prefix}."
  out = ""
  out << "#{prefix}::\n" if size.size > 1
  out << "#{pref}type:: #{type}\n"
  out << "#{pref}value:: #{value}\n"
end

#to_hash<Type>

Render BibliographicSize::Value object to hash.

Returns:

  • (<Type>)

    <description>



82
83
84
# File 'lib/relaton_bib/bibliographic_size.rb', line 82

def to_hash
  { type: type, value: value }
end

#to_xml(builder) ⇒ Object

Render BibliographicSize::Value object to XML.

Parameters:

  • builder (Nokogiri::XML::Builder)

    the XML builder



73
74
75
# File 'lib/relaton_bib/bibliographic_size.rb', line 73

def to_xml(builder)
  builder.value value, type: type
end