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(**args) ⇒ Medium

Initialize a Medium object.

Parameters:

  • content (String, nil)

    content of the medium

  • genre (String, nil)

    genre of the medium

  • form (String, nil)

    form of the medium

  • carrier (String, nil)

    carrier of the medium

  • size (String, nil)

    size of the medium

  • scale (String, nil)


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

def initialize(**args)
  @content = args[:content]
  @genre   = args[:genre]
  @form    = args[:form]
  @carrier = args[:carrier]
  @size    = args[:size]
  @scale   = args[:scale]
end

Instance Attribute Details

#carrierString? (readonly)

Returns:

  • (String, nil)


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

def carrier
  @carrier
end

#contentString? (readonly)

Returns:

  • (String, nil)


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

def content
  @content
end

#formString? (readonly)

Returns:

  • (String, nil)


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

def form
  @form
end

#genreString? (readonly)

Returns:

  • (String, nil)


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

def genre
  @genre
end

#scaleString? (readonly)

Returns:

  • (String, nil)


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

def scale
  @scale
end

#sizeString? (readonly)

Returns:

  • (String, nil)


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

def size
  @size
end

Instance Method Details

#to_asciibib(prefix = "") ⇒ String

Render Medium object to AsciiBib.

Parameters:

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

Returns:

  • (String)


64
65
66
67
68
69
70
71
72
73
74
# File 'lib/relaton_bib/medium.rb', line 64

def to_asciibib(prefix = "") # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
  pref = prefix.empty? ? "medium." : "#{prefix}.medium."
  out = ""
  out += "#{pref}content:: #{content}\n" if content
  out += "#{pref}genre:: #{genre}\n" if genre
  out += "#{pref}form:: #{form}\n" if form
  out += "#{pref}carrier:: #{carrier}\n" if carrier
  out += "#{pref}size:: #{size}\n" if size
  out += "#{pref}scale:: #{scale}\n" if scale
  out
end

#to_hashHash

Render Medium object to hash.

Returns:

  • (Hash)


46
47
48
49
50
51
52
53
54
55
# File 'lib/relaton_bib/medium.rb', line 46

def to_hash # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
  hash = {}
  hash["content"] = content if content
  hash["genre"] = genre if genre
  hash["form"] = form if form
  hash["carrier"] = carrier if carrier
  hash["size"] = size if size
  hash["scale"] = scale if scale
  hash
end

#to_xml(builder) ⇒ Object

Render Medium object to XML.

Parameters:

  • builder (Nokogiri::XML::Builder)


30
31
32
33
34
35
36
37
38
39
# File 'lib/relaton_bib/medium.rb', line 30

def to_xml(builder) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity
  builder.medium do
    builder.content content if content
    builder.genre genre if genre
    builder.form form if form
    builder.carrier carrier if carrier
    builder.size size if size
    builder.scale scale if scale
  end
end