Class: RelatonUn::Session
- Inherits:
-
Object
- Object
- RelatonUn::Session
- Includes:
- RelatonBib
- Defined in:
- lib/relaton_un/session.rb
Instance Attribute Summary collapse
- #agenda_id ⇒ String, NilClass readonly
- #collaborator ⇒ String, NilClass readonly
- #item_footnote ⇒ String, NilClass readonly
- #item_name ⇒ Array<String> readonly
- #item_number ⇒ Array<String> readonly
- #session_date ⇒ Date, NilClass readonly
- #session_number ⇒ String, NilClass readonly
- #subitem_name ⇒ Array<String> readonly
Instance Method Summary collapse
-
#initialize(**args) ⇒ Session
constructor
A new instance of Session.
- #to_asciibib(prefix = "") ⇒ String
-
#to_hash ⇒ Hash
rubocop:disable Metrics/PerceivedComplexity, Metrics/MethodLength.
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(**args) ⇒ Session
Returns a new instance of Session.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/relaton_un/session.rb', line 22 def initialize(**args) @session_number = args[:session_number] @session_date = Date.parse args[:session_date] if args[:session_date] @item_number = args.fetch(:item_number, []) @item_name = args.fetch(:item_name, []) @subitem_name = args.fetch(:subitem_name, []) @collaborator = args[:collaborator] @agenda_id = args[:agenda_id] @item_footnote = args[:item_footnote] end |
Instance Attribute Details
#agenda_id ⇒ String, NilClass (readonly)
6 7 8 |
# File 'lib/relaton_un/session.rb', line 6 def agenda_id @agenda_id end |
#collaborator ⇒ String, NilClass (readonly)
6 7 8 |
# File 'lib/relaton_un/session.rb', line 6 def collaborator @collaborator end |
#item_footnote ⇒ String, NilClass (readonly)
6 7 8 |
# File 'lib/relaton_un/session.rb', line 6 def item_footnote @item_footnote end |
#item_name ⇒ Array<String> (readonly)
12 13 14 |
# File 'lib/relaton_un/session.rb', line 12 def item_name @item_name end |
#item_number ⇒ Array<String> (readonly)
12 13 14 |
# File 'lib/relaton_un/session.rb', line 12 def item_number @item_number end |
#session_date ⇒ Date, NilClass (readonly)
9 10 11 |
# File 'lib/relaton_un/session.rb', line 9 def session_date @session_date end |
#session_number ⇒ String, NilClass (readonly)
6 7 8 |
# File 'lib/relaton_un/session.rb', line 6 def session_number @session_number end |
#subitem_name ⇒ Array<String> (readonly)
12 13 14 |
# File 'lib/relaton_un/session.rb', line 12 def subitem_name @subitem_name end |
Instance Method Details
#to_asciibib(prefix = "") ⇒ String
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/relaton_un/session.rb', line 71 def to_asciibib(prefix = "") pref = prefix.empty? ? prefix : prefix + "." pref += "session" out = "" out += "#{pref}.session_number:: #{session_number}\n" if session_number out += "#{pref}.session_date:: #{session_date}\n" if session_date item_number.each { |n| out += "#{pref}.item_number:: #{n}\n" } item_name.each { |n| out += "#{pref}.item_name:: #{n}\n" } subitem_name.each { |n| out += "#{pref}.subitem_name:: #{n}\n" } out += "#{pref}.collaborator:: #{collaborator}\n" if collaborator out += "#{pref}.agenda_id:: #{agenda_id}\n" if agenda_id out += "#{pref}.item_footnote:: #{item_footnote}\n" if item_footnote out end |
#to_hash ⇒ Hash
rubocop:disable Metrics/PerceivedComplexity, Metrics/MethodLength
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/relaton_un/session.rb', line 51 def to_hash hash = {} hash["session_number"] = session_number if session_number hash["session_date"] = session_date.to_s if session_date if item_number.any? hash["item_number"] = single_element_array(item_number) end hash["item_name"] = single_element_array(item_name) if item_name.any? if subitem_name.any? hash["subitem_name"] = single_element_array(subitem_name) end hash["collaborator"] = collaborator if collaborator hash["agenda_id"] = agenda_id if agenda_id hash["item_footnote"] = item_footnote if item_footnote hash end |
#to_xml(builder) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/relaton_un/session.rb', line 36 def to_xml(builder) builder.session do |b| b.number session_number if session_number b.send "session-date", session_date.to_s if session_date item_number.each { |n| b.send "item-number", n } item_name.each { |n| b.send "item-name", n } subitem_name.each { |n| b.send "subitem-name", n } b.collaborator collaborator if collaborator b.send "agenda-id", agenda_id if agenda_id b.send "item-footnote", item_footnote if item_footnote end end |