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.xpath('xmlns:ExtentType').try(:text)
  @value = data.xpath('xmlns:ExtentValue').try(:text).try(:to_i)
  @unit = data.xpath('xmlns:ExtentUnit').try(:text)
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

#eidObject



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

def eid
  @type.to_i
end

#idObject



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

def id
  Kernel.warn "[DEPRECATION] `id` is deprecated. Please use `eid` instead."
  eid
end

#inspect_include_fieldsObject



47
48
49
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 47

def inspect_include_fields
  [:type_name, :unit_name]
end

#type_nameObject



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

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

#unit_nameObject



43
44
45
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 43

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