Class: Elibri::ONIX::Release_3_0::Extent

Inherits:
Object
  • Object
show all
Defined in:
lib/elibri_onix/onix_3_0/extent.rb

Constant Summary collapse

ATTRIBUTES =

from ONIX documentation: covers product extents, in terms of pages, running times, file sizes etc, as may be appropriate to each media type. For products whose content is primarily readable text, it also covers illustrations and other kinds of ancillary matter such as the inclusion of a bibliography or index.

[
  :type, :value, :unit, :type_name, :unit_name
]
RELATIONS =
[
  :inspect_include_fields
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Extent

Returns a new instance of Extent.



23
24
25
26
27
28
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 23

def initialize(data)
  @to_xml = data.to_s
  @type = data.css('ExtentType').try(:text).try(:strip)
  @value = data.css('ExtentValue').try(:text).try(:strip).try(:to_i)
  @unit = data.css('ExtentUnit').try(:text).try(:strip)
end

Instance Attribute Details

#to_xmlObject

Returns the value of attribute to_xml.



21
22
23
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 21

def to_xml
  @to_xml
end

#typeObject

Returns the value of attribute type.



21
22
23
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 21

def type
  @type
end

#unitObject

Returns the value of attribute unit.



21
22
23
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 21

def unit
  @unit
end

#valueObject

Returns the value of attribute value.



21
22
23
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 21

def value
  @value
end

Instance Method Details

#inspect_include_fieldsObject



38
39
40
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 38

def inspect_include_fields
  [:type_name, :unit_name]
end

#type_nameObject



30
31
32
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 30

def type_name
  Elibri::ONIX::Dict::Release_3_0::ExtentType.find_by_onix_code(@type).try(:const_name).try(:downcase)
end

#unit_nameObject



34
35
36
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 34

def unit_name
  Elibri::ONIX::Dict::Release_3_0::ExtentUnit.find_by_onix_code(@unit).try(:const_name).try(:downcase)
end