Class: RelatonBib::Medium

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(form: nil, size: nil, scale: nil) ⇒ Medium

Returns a new instance of Medium.

Parameters:

  • form (String, NilClass) (defaults to: nil)
  • size (String, NilClass) (defaults to: nil)
  • scale (String, NilClass) (defaults to: nil)


9
10
11
12
13
# File 'lib/relaton_bib/medium.rb', line 9

def initialize(form: nil, size: nil, scale: nil)
  @form  = form
  @size  = size
  @scale = scale
end

Instance Attribute Details

#formString, NilClass (readonly)

Returns:

  • (String, NilClass)


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

def form
  @form
end

#scaleString, NilClass (readonly)

Returns:

  • (String, NilClass)


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

def scale
  @scale
end

#sizeString, NilClass (readonly)

Returns:

  • (String, NilClass)


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

def size
  @size
end

Instance Method Details

#to_asciibib(prefix = "") ⇒ String

Parameters:

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

Returns:

  • (String)


35
36
37
38
39
40
41
42
# File 'lib/relaton_bib/medium.rb', line 35

def to_asciibib(prefix = "")
  pref = prefix.empty? ? "medium." : prefix + ".medium."
  out = ""
  out += "#{pref}form:: #{form}\n" if form
  out += "#{pref}size:: #{size}\n" if size
  out += "#{pref}scale:: #{scale}\n" if scale
  out
end

#to_hashHash

Returns:

  • (Hash)


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

def to_hash
  hash = {}
  hash["form"] = form if form
  hash["size"] = size if size
  hash["scale"] = scale if scale
  hash
end

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


16
17
18
19
20
21
22
# File 'lib/relaton_bib/medium.rb', line 16

def to_xml(builder)
  builder.medium do
    builder.form form if form
    builder.size size if size
    builder.scale scale if scale
  end
end