Class: Elibri::ONIX::Release_3_0::Collection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Collection

Returns a new instance of Collection.



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

def initialize(data)
  @to_xml = data.to_s
  @type = data.at_css('CollectionType')&.text
  @elements = data.css('TitleElement').map { |element_data| TitleElement.new(element_data) }
  @title_detail = TitleDetail.new(data.at_css('TitleDetail')) if data.at_css('TitleDetail')
end

Instance Attribute Details

#elementsObject

Returns the value of attribute elements.



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

def elements
  @elements
end

#title_detailObject

Returns the value of attribute title_detail.



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

def title_detail
  @title_detail
end

#to_xmlObject

Returns the value of attribute to_xml.



6
7
8
# File 'lib/elibri_onix/onix_3_0/collection.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/collection.rb', line 6

def type
  @type
end

Instance Method Details

#full_titleObject



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

def full_title
  title_detail&.full_title
end

#inspect_include_fieldsObject



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

def inspect_include_fields
  [:type_name]
end

#type_nameObject



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

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