Class: Elibri::ONIX::Release_3_0::PublishingDate
- Inherits:
-
Object
- Object
- Elibri::ONIX::Release_3_0::PublishingDate
- Defined in:
- lib/elibri_onix/onix_3_0/publishing_date.rb
Instance Attribute Summary collapse
-
#date ⇒ Object
Returns the value of attribute date.
-
#format ⇒ Object
Returns the value of attribute format.
-
#role ⇒ Object
Returns the value of attribute role.
-
#to_xml ⇒ Object
Returns the value of attribute to_xml.
Instance Method Summary collapse
-
#initialize(data) ⇒ PublishingDate
constructor
A new instance of PublishingDate.
- #parsed ⇒ Object
Constructor Details
#initialize(data) ⇒ PublishingDate
Returns a new instance of PublishingDate.
8 9 10 11 12 13 |
# File 'lib/elibri_onix/onix_3_0/publishing_date.rb', line 8 def initialize(data) @to_xml = data.to_s @role = data.at_css('PublishingDateRole')&.text @format = data.at_css('DateFormat')&.text || data.at_css('Date')['dateformat'] || '00' @date = data.at_css('Date')&.text end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
6 7 8 |
# File 'lib/elibri_onix/onix_3_0/publishing_date.rb', line 6 def date @date end |
#format ⇒ Object
Returns the value of attribute format.
6 7 8 |
# File 'lib/elibri_onix/onix_3_0/publishing_date.rb', line 6 def format @format end |
#role ⇒ Object
Returns the value of attribute role.
6 7 8 |
# File 'lib/elibri_onix/onix_3_0/publishing_date.rb', line 6 def role @role end |
#to_xml ⇒ Object
Returns the value of attribute to_xml.
6 7 8 |
# File 'lib/elibri_onix/onix_3_0/publishing_date.rb', line 6 def to_xml @to_xml end |
Instance Method Details
#parsed ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/elibri_onix/onix_3_0/publishing_date.rb', line 15 def parsed case @format when '00' then [date[0...4].to_i, date[4...6].to_i, date[6...8].to_i] when '01' then [date[0...4].to_i, date[4...6].to_i] when '05' then [date[0...4].to_i] end end |