class Elibri::ONIX::Release_3_0::PublishingDate

Constants

ATTRIBUTES
RELATIONS

Attributes

date[RW]
format[RW]
role[RW]
to_xml[RW]

Public Class Methods

new(data) click to toggle source
# File lib/elibri_onix/onix_3_0/publishing_date.rb, line 25
def initialize(data)
  @to_xml = data.to_s
  @role = data.at_css('PublishingDateRole').try(:text)
  @format = data.at_css('DateFormat').try(:text) || data.at_css('Date')['dateformat'] || '00'
  @date = data.at_css('Date').try(:text)
end

Public Instance Methods

parsed() click to toggle source
# 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