Class: Elibri::ONIX::Release_3_0::PublishingDate
- Inherits:
-
Object
- Object
- Elibri::ONIX::Release_3_0::PublishingDate
- Includes:
- HashId
- Defined in:
- lib/elibri_onix/onix_3_0/publishing_date.rb
Constant Summary collapse
- ATTRIBUTES =
[ :role, :format, :date, :parsed ]
- RELATIONS =
[]
Constants included from HashId
HashId::SKIPPED_2, HashId::SKIPPED_ATTRIBS
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
Methods included from HashId
Constructor Details
#initialize(data) ⇒ PublishingDate
Returns a new instance of PublishingDate.
25 26 27 28 29 30 |
# File 'lib/elibri_onix/onix_3_0/publishing_date.rb', line 25 def initialize(data) @to_xml = data.to_s @role = data.at_xpath('xmlns:PublishingDateRole').try(:text) @format = data.at_xpath('xmlns:DateFormat').try(:text) @date = data.at_xpath('xmlns:Date').try(:text) end |
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/publishing_date.rb', line 23 def date @date end |
#format ⇒ Object
Returns the value of attribute format.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/publishing_date.rb', line 23 def format @format end |
#role ⇒ Object
Returns the value of attribute role.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/publishing_date.rb', line 23 def role @role end |
#to_xml ⇒ Object
Returns the value of attribute to_xml.
23 24 25 |
# File 'lib/elibri_onix/onix_3_0/publishing_date.rb', line 23 def to_xml @to_xml end |
Instance Method Details
#parsed ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/elibri_onix/onix_3_0/publishing_date.rb', line 32 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 |