Class: RelatonBib::BibliographicSize

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

Defined Under Namespace

Classes: Value

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(size) ⇒ BibliographicSize

Initialize a BibliographicSize object.

Parameters:

  • size (<Type>)

    <description>



15
16
17
# File 'lib/relaton_bib/bibliographic_size.rb', line 15

def initialize(size)
  @size = size
end

Instance Attribute Details

#sizeArray<RelatonBib::BibliographicSize::Value> (readonly)



8
9
10
# File 'lib/relaton_bib/bibliographic_size.rb', line 8

def size
  @size
end

Instance Method Details

#to_asciibib(prefix = "") ⇒ String

Render BibliographicSize object to AsciiBib.

Parameters:

  • prefix (String) (defaults to: "")

    prefix for the size

Returns:

  • (String)

    AsciiBib string



39
40
41
42
# File 'lib/relaton_bib/bibliographic_size.rb', line 39

def to_asciibib(prefix = "")
  pref = prefix.empty? ? "size" : "#{prefix}.size"
  size.map { |s| s.to_asciibib pref, size.size }.join
end

#to_hash<Type>

Render BibliographicSize object to hash.

Returns:

  • (<Type>)

    <description>



49
50
51
# File 'lib/relaton_bib/bibliographic_size.rb', line 49

def to_hash
  size.map &:to_hash
end

#to_xml(builder) ⇒ Object

Render BibliographicSize object to XML.

Parameters:

  • builder (Nokogiri::XML::Builder)

    the XML builder



24
25
26
27
28
29
30
# File 'lib/relaton_bib/bibliographic_size.rb', line 24

def to_xml(builder)
  return if size.empty?

  builder.size do
    size.each { |s| s.to_xml builder }
  end
end