Class: Elibri::ONIX::Release_3_0::Measure
- Inherits:
-
Object
- Object
- Elibri::ONIX::Release_3_0::Measure
- Includes:
- HashId
- Defined in:
- lib/elibri_onix/onix_3_0/measure.rb
Overview
klasa abstahuje parsowanie wymiarów książki.
Constant Summary collapse
- ATTRIBUTES =
[ :type, :measurement, :unit, :type_name ]
- RELATIONS =
[ :inspect_include_fields ]
Constants included from HashId
HashId::SKIPPED_2, HashId::SKIPPED_ATTRIBS
Instance Attribute Summary collapse
-
#measurement ⇒ Object
Returns the value of attribute measurement.
-
#to_xml ⇒ Object
Returns the value of attribute to_xml.
-
#type ⇒ Object
Returns the value of attribute type.
-
#type_name ⇒ Object
Returns the value of attribute type_name.
-
#unit ⇒ Object
Returns the value of attribute unit.
Instance Method Summary collapse
-
#id ⇒ Object
def eid @type.to_i end.
-
#initialize(data) ⇒ Measure
constructor
A new instance of Measure.
- #inspect_include_fields ⇒ Object
Methods included from HashId
Constructor Details
#initialize(data) ⇒ Measure
Returns a new instance of Measure.
21 22 23 24 25 26 27 |
# File 'lib/elibri_onix/onix_3_0/measure.rb', line 21 def initialize(data) @to_xml = data.to_s @type = data.at_xpath('xmlns:MeasureType').try(:text) @measurement = data.at_xpath('xmlns:Measurement').try(:text).try(:to_i) @unit = data.at_xpath('xmlns:MeasureUnitCode').try(:text) end |
Instance Attribute Details
#measurement ⇒ Object
Returns the value of attribute measurement.
19 20 21 |
# File 'lib/elibri_onix/onix_3_0/measure.rb', line 19 def measurement @measurement end |
#to_xml ⇒ Object
Returns the value of attribute to_xml.
19 20 21 |
# File 'lib/elibri_onix/onix_3_0/measure.rb', line 19 def to_xml @to_xml end |
#type ⇒ Object
Returns the value of attribute type.
19 20 21 |
# File 'lib/elibri_onix/onix_3_0/measure.rb', line 19 def type @type end |
#type_name ⇒ Object
Returns the value of attribute type_name.
19 20 21 |
# File 'lib/elibri_onix/onix_3_0/measure.rb', line 19 def type_name @type_name end |
#unit ⇒ Object
Returns the value of attribute unit.
19 20 21 |
# File 'lib/elibri_onix/onix_3_0/measure.rb', line 19 def unit @unit end |
Instance Method Details
#id ⇒ Object
def eid
@type.to_i
end
41 42 43 44 |
# File 'lib/elibri_onix/onix_3_0/measure.rb', line 41 def id Kernel.warn "[DEPRECATION] `id` is deprecated. Please use `eid` instead." eid end |
#inspect_include_fields ⇒ Object
33 34 35 |
# File 'lib/elibri_onix/onix_3_0/measure.rb', line 33 def inspect_include_fields [:type_name] end |