Class: Elibri::ONIX::Release_3_0::SupportingResource

Inherits:
Object
  • Object
show all
Includes:
ExternalId, ExternalTimestamp, Inspector
Defined in:
lib/elibri_onix/onix_3_0/supporting_resource.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Inspector

#attribute_for_inspect, #inspect

Methods included from ExternalTimestamp

#datestamp, included, #set_datestamp

Methods included from ExternalId

#eid, included, #set_eid

Constructor Details

#initialize(data) ⇒ SupportingResource

Returns a new instance of SupportingResource.



12
13
14
15
16
17
18
19
20
21
# File 'lib/elibri_onix/onix_3_0/supporting_resource.rb', line 12

def initialize(data)
  @data = data
  @to_xml = data.to_s
  @content_type = data.at_css('ResourceContentType')&.text
  @mode = data.at_css('ResourceMode')&.text
  @form = data.at_css('ResourceVersion').at_css('ResourceForm')&.text
  @link = data.at_css('ResourceVersion').at_css('ResourceLink')&.text
  set_eid(data)
  set_datestamp(data)
end

Instance Attribute Details

#content_typeObject

Returns the value of attribute content_type.



10
11
12
# File 'lib/elibri_onix/onix_3_0/supporting_resource.rb', line 10

def content_type
  @content_type
end

#dataObject

Returns the value of attribute data.



10
11
12
# File 'lib/elibri_onix/onix_3_0/supporting_resource.rb', line 10

def data
  @data
end

#formObject

Returns the value of attribute form.



10
11
12
# File 'lib/elibri_onix/onix_3_0/supporting_resource.rb', line 10

def form
  @form
end

Returns the value of attribute link.



10
11
12
# File 'lib/elibri_onix/onix_3_0/supporting_resource.rb', line 10

def link
  @link
end

#modeObject

Returns the value of attribute mode.



10
11
12
# File 'lib/elibri_onix/onix_3_0/supporting_resource.rb', line 10

def mode
  @mode
end

#to_xmlObject

Returns the value of attribute to_xml.



10
11
12
# File 'lib/elibri_onix/onix_3_0/supporting_resource.rb', line 10

def to_xml
  @to_xml
end

Instance Method Details

#content_type_nameObject



23
24
25
26
27
28
29
30
# File 'lib/elibri_onix/onix_3_0/supporting_resource.rb', line 23

def content_type_name
  content_type = Elibri::ONIX::Dict::Release_3_0::ResourceContentType.find_by_onix_code(@content_type)
  if content_type
    content_type.const_name.downcase
  else
    raise ArgumentError, "Cannot find ResourceContentType for #{@content_type}"
  end
end

#form_nameObject



40
41
42
# File 'lib/elibri_onix/onix_3_0/supporting_resource.rb', line 40

def form_name
  Elibri::ONIX::Dict::Release_3_0::ResourceForm.find_by_onix_code(@form).const_name.downcase
end

#inspect_include_fieldsObject



44
45
46
# File 'lib/elibri_onix/onix_3_0/supporting_resource.rb', line 44

def inspect_include_fields
  [:content_type_name, :mode_name, :form_name]
end

#mode_nameObject

def audience_name

Elibri::ONIX::Dict::Release_3_0::ContentAudience.find_by_onix_code(audience).const_name.downcase

end



36
37
38
# File 'lib/elibri_onix/onix_3_0/supporting_resource.rb', line 36

def mode_name
  Elibri::ONIX::Dict::Release_3_0::ResourceMode.find_by_onix_code(@mode).const_name.downcase
end