Class: RelatonBib::ICS
Instance Attribute Summary collapse
- #code ⇒ String readonly
- #text ⇒ String? readonly
Instance Method Summary collapse
-
#initialize(code:, text: nil) ⇒ ICS
constructor
A new instance of ICS.
- #to_asciibib(prefix = "", count = 1) ⇒ String
- #to_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(code:, text: nil) ⇒ ICS
Returns a new instance of ICS.
11 12 13 14 |
# File 'lib/relaton_bib/ics.rb', line 11 def initialize(code:, text: nil) @code = code @text = text end |
Instance Attribute Details
#code ⇒ String (readonly)
4 5 6 |
# File 'lib/relaton_bib/ics.rb', line 4 def code @code end |
#text ⇒ String? (readonly)
7 8 9 |
# File 'lib/relaton_bib/ics.rb', line 7 def text @text end |
Instance Method Details
#to_asciibib(prefix = "", count = 1) ⇒ String
34 35 36 37 38 39 40 |
# File 'lib/relaton_bib/ics.rb', line 34 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" if text out end |
#to_hash ⇒ Hash
25 26 27 28 29 |
# File 'lib/relaton_bib/ics.rb', line 25 def to_hash hash = { "code" => code } hash["text"] = text if text hash end |
#to_xml(builder) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/relaton_bib/ics.rb', line 17 def to_xml(builder) builder.ics do |b| b.code code b.text_ text if text end end |