Class: RelatonBib::ICS

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(code:, text:) ⇒ ICS

Returns a new instance of ICS.

Parameters:

  • code (String)
  • text (String)


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

def initialize(code:, text:)
  @code = code
  @text = text
end

Instance Attribute Details

#codeString (readonly)

Returns:

  • (String)


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

def code
  @code
end

#textString (readonly)

Returns:

  • (String)


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

def text
  @text
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)


29
30
31
32
33
34
35
# File 'lib/relaton_bib/ics.rb', line 29

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

#to_hashHash

Returns:

  • (Hash)


22
23
24
# File 'lib/relaton_bib/ics.rb', line 22

def to_hash
  { "code" => code, "text" => text }
end

#to_xml(builder) ⇒ Object

Parameters:

  • builder (Nokogiri::XML::Builder)


14
15
16
17
18
19
# File 'lib/relaton_bib/ics.rb', line 14

def to_xml(builder)
  builder.ics do |b|
    b.code code
    b.text_ text
  end
end