Class: RelatonIsoBib::Ics

Inherits:
Isoics::ICS
  • Object
show all
Defined in:
lib/relaton_iso_bib/ics.rb

Overview

Iso ICS classificator.

Instance Method Summary collapse

Constructor Details

#initialize(code = nil, field: nil, group: nil, subgroup: nil) ⇒ Ics

Returns a new instance of Ics.

Parameters:

  • code (String, NilClass) (defaults to: nil)
  • field (Integer, NilClass) (defaults to: nil)
  • group (Integer, NilClass) (defaults to: nil)
  • subgroup (Integer, NilClass) (defaults to: nil)


8
9
10
11
12
13
14
15
16
# File 'lib/relaton_iso_bib/ics.rb', line 8

def initialize(code = nil, field: nil, group: nil, subgroup: nil)
  unless code || field
    raise ArgumentError,
          "wrong arguments (should be string or { fieldcode: [String] }"
  end

  field, group, subgroup = code.split "." if code
  super fieldcode: field, groupcode: group, subgroupcode: subgroup
end

Instance Method Details

#to_asciibib(prefix = "", count = 1) ⇒ String

Parameters:

  • prefix (String) (defaults to: "")
  • count (Integer) (defaults to: 1)

    number of ICS

Returns:

  • (String)


37
38
39
40
41
42
43
44
# File 'lib/relaton_iso_bib/ics.rb', line 37

def to_asciibib(prefix = "", count = 1)
  pref = prefix.empty? ? prefix : prefix + "."
  pref += "ics"
  out = count > 1 ? "#{pref}::\n" : ""
  out += "#{pref}.code:: #{code}\n"
  out += "#{pref}.description:: #{description}\n"
  out
end

#to_hashHash

Returns:

  • (Hash)


27
28
29
30
31
32
# File 'lib/relaton_iso_bib/ics.rb', line 27

def to_hash
  hash = {}
  hash["code"] = code if code
  hash["text"] = description if description
  hash
end

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


19
20
21
22
23
24
# File 'lib/relaton_iso_bib/ics.rb', line 19

def to_xml(builder)
  builder.ics do
    builder.code code
    builder.text_ description
  end
end