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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Extent

Returns a new instance of Extent.



8
9
10
11
12
13
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 8

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

Instance Attribute Details

#to_xmlObject

Returns the value of attribute to_xml.



6
7
8
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 6

def to_xml
  @to_xml
end

#typeObject

Returns the value of attribute type.



6
7
8
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 6

def type
  @type
end

#unitObject

Returns the value of attribute unit.



6
7
8
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 6

def unit
  @unit
end

#valueObject

Returns the value of attribute value.



6
7
8
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 6

def value
  @value
end

Instance Method Details

#inspect_include_fieldsObject



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

def inspect_include_fields
  [:type_name, :unit_name]
end

#type_nameObject



15
16
17
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 15

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

#unit_nameObject



19
20
21
# File 'lib/elibri_onix/onix_3_0/extent.rb', line 19

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