Class: Elibri::ONIX::Release_3_0::TextContent

Inherits:
Object
  • Object
show all
Includes:
ExternalId, ExternalTimestamp, Inspector
Defined in:
lib/elibri_onix/onix_3_0/text_content.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) ⇒ TextContent

Returns a new instance of TextContent.



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

def initialize(data)
  @to_xml = data.to_s
  @type = data.at_css('TextType')&.text
  @author = data.at_css('TextAuthor')&.text
  @source_title = data.at_css('SourceTitle')&.text
  if data.at_css('Text')
    @text = data.at_css('Text').children.find { |x| x.cdata? }&.text #cdata => true ?
    @source_url =  data.at_css('Text').attribute('sourcename')&.text
  end
  set_eid(data)
  set_datestamp(data)
end

Instance Attribute Details

#authorObject

Returns the value of attribute author.



9
10
11
# File 'lib/elibri_onix/onix_3_0/text_content.rb', line 9

def author
  @author
end

#source_titleObject

Returns the value of attribute source_title.



9
10
11
# File 'lib/elibri_onix/onix_3_0/text_content.rb', line 9

def source_title
  @source_title
end

#source_urlObject

Returns the value of attribute source_url.



9
10
11
# File 'lib/elibri_onix/onix_3_0/text_content.rb', line 9

def source_url
  @source_url
end

#textObject

Returns the value of attribute text.



9
10
11
# File 'lib/elibri_onix/onix_3_0/text_content.rb', line 9

def text
  @text
end

#to_xmlObject

Returns the value of attribute to_xml.



9
10
11
# File 'lib/elibri_onix/onix_3_0/text_content.rb', line 9

def to_xml
  @to_xml
end

#typeObject

Returns the value of attribute type.



9
10
11
# File 'lib/elibri_onix/onix_3_0/text_content.rb', line 9

def type
  @type
end

Instance Method Details

#inspect_include_fieldsObject



29
30
31
# File 'lib/elibri_onix/onix_3_0/text_content.rb', line 29

def inspect_include_fields
  [:type_name, :text]
end

#type_nameObject



24
25
26
# File 'lib/elibri_onix/onix_3_0/text_content.rb', line 24

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