Class: Elibri::ONIX::Release_3_0::TitleDetail
- Inherits:
-
Object
- Object
- Elibri::ONIX::Release_3_0::TitleDetail
- Defined in:
- lib/elibri_onix/onix_3_0/title_detail.rb
Instance Attribute Summary collapse
-
#elements ⇒ Object
Returns the value of attribute elements.
-
#to_xml ⇒ Object
Returns the value of attribute to_xml.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #collection_level ⇒ Object
- #collection_level_title ⇒ Object
- #full_title ⇒ Object
-
#initialize(data) ⇒ TitleDetail
constructor
A new instance of TitleDetail.
- #inspect_include_fields ⇒ Object
- #product_level ⇒ Object
- #product_level_title ⇒ Object
- #type_name ⇒ Object
Constructor Details
#initialize(data) ⇒ TitleDetail
8 9 10 11 12 |
# File 'lib/elibri_onix/onix_3_0/title_detail.rb', line 8 def initialize(data) @to_xml = data.to_s @type = data.at_css('TitleType')&.text @elements = data.css('TitleElement').map { |element_data| TitleElement.new(element_data) } end |
Instance Attribute Details
#elements ⇒ Object
Returns the value of attribute elements.
6 7 8 |
# File 'lib/elibri_onix/onix_3_0/title_detail.rb', line 6 def elements @elements end |
#to_xml ⇒ Object
Returns the value of attribute to_xml.
6 7 8 |
# File 'lib/elibri_onix/onix_3_0/title_detail.rb', line 6 def to_xml @to_xml end |
#type ⇒ Object
Returns the value of attribute type.
6 7 8 |
# File 'lib/elibri_onix/onix_3_0/title_detail.rb', line 6 def type @type end |
Instance Method Details
#collection_level ⇒ Object
44 45 46 |
# File 'lib/elibri_onix/onix_3_0/title_detail.rb', line 44 def collection_level @elements.find {|element| element.level == "02"} end |
#collection_level_title ⇒ Object
40 41 42 |
# File 'lib/elibri_onix/onix_3_0/title_detail.rb', line 40 def collection_level_title collection_level&.full_title end |
#full_title ⇒ Object
22 23 24 25 26 27 28 29 30 |
# File 'lib/elibri_onix/onix_3_0/title_detail.rb', line 22 def full_title String.new.tap do |_full_title| _full_title << collection_level_title if collection_level_title && collection_level_title.size > 0 if product_level_title && product_level_title.size > 0 _full_title << ". " if _full_title && _full_title.size > 0 _full_title << product_level_title end end end |
#inspect_include_fields ⇒ Object
18 19 20 |
# File 'lib/elibri_onix/onix_3_0/title_detail.rb', line 18 def inspect_include_fields [:type_name] end |
#product_level ⇒ Object
36 37 38 |
# File 'lib/elibri_onix/onix_3_0/title_detail.rb', line 36 def product_level @elements.find {|element| element.level == "01"} end |
#product_level_title ⇒ Object
32 33 34 |
# File 'lib/elibri_onix/onix_3_0/title_detail.rb', line 32 def product_level_title product_level&.full_title end |
#type_name ⇒ Object
14 15 16 |
# File 'lib/elibri_onix/onix_3_0/title_detail.rb', line 14 def type_name Elibri::ONIX::Dict::Release_3_0::TitleType.find_by_onix_code(self.type).const_name.downcase end |