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

Constant Summary collapse

ATTRIBUTES =

:nodoc:

[
  :type, :author, :source_title, :text, :source_url, :type_name
]
RELATIONS =

:nodoc:

[
  :inspect_include_fields
]

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, #id, included, #set_eid

Constructor Details

#initialize(data) ⇒ TextContent

Returns a new instance of TextContent.



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/elibri_onix/onix_3_0/text_content.rb', line 26

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

Instance Attribute Details

#authorObject

Returns the value of attribute author.



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

def author
  @author
end

#source_titleObject

Returns the value of attribute source_title.



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

def source_title
  @source_title
end

#source_urlObject

Returns the value of attribute source_url.



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

def source_url
  @source_url
end

#textObject

Returns the value of attribute text.



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

def text
  @text
end

#to_xmlObject

Returns the value of attribute to_xml.



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

def to_xml
  @to_xml
end

#typeObject

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#inspect_include_fieldsObject



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

def inspect_include_fields
  [:type_name, :text]
end

#type_nameObject



39
40
41
# File 'lib/elibri_onix/onix_3_0/text_content.rb', line 39

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