Class: Elibri::ONIX::Release_3_0::TitleElement
- Inherits:
-
Object
- Object
- Elibri::ONIX::Release_3_0::TitleElement
- Includes:
- HashId
- Defined in:
- lib/elibri_onix/onix_3_0/title_element.rb
Constant Summary collapse
- ATTRIBUTES =
[ :level, :part_number, :title, :subtitle, :full_title ]
- RELATIONS =
[]
Constants included from HashId
HashId::SKIPPED_2, HashId::SKIPPED_ATTRIBS
Instance Attribute Summary collapse
-
#level ⇒ Object
Returns the value of attribute level.
-
#part_number ⇒ Object
Returns the value of attribute part_number.
-
#subtitle ⇒ Object
Returns the value of attribute subtitle.
-
#title ⇒ Object
Returns the value of attribute title.
-
#to_xml ⇒ Object
Returns the value of attribute to_xml.
Instance Method Summary collapse
- #full_title ⇒ Object
-
#initialize(data) ⇒ TitleElement
constructor
A new instance of TitleElement.
Methods included from HashId
Constructor Details
#initialize(data) ⇒ TitleElement
Returns a new instance of TitleElement.
31 32 33 34 35 36 37 |
# File 'lib/elibri_onix/onix_3_0/title_element.rb', line 31 def initialize(data) @to_xml = data.to_s @level = data.at_xpath('xmlns:TitleElementLevel').try(:text) @part_number = data.at_xpath('xmlns:PartNumber').try(:text) @title = data.at_xpath('xmlns:TitleText').try(:text) @subtitle = data.at_xpath('xmlns:Subtitle').try(:text) end |
Instance Attribute Details
#level ⇒ Object
Returns the value of attribute level.
29 30 31 |
# File 'lib/elibri_onix/onix_3_0/title_element.rb', line 29 def level @level end |
#part_number ⇒ Object
Returns the value of attribute part_number.
29 30 31 |
# File 'lib/elibri_onix/onix_3_0/title_element.rb', line 29 def part_number @part_number end |
#subtitle ⇒ Object
Returns the value of attribute subtitle.
29 30 31 |
# File 'lib/elibri_onix/onix_3_0/title_element.rb', line 29 def subtitle @subtitle end |
#title ⇒ Object
Returns the value of attribute title.
29 30 31 |
# File 'lib/elibri_onix/onix_3_0/title_element.rb', line 29 def title @title end |
#to_xml ⇒ Object
Returns the value of attribute to_xml.
29 30 31 |
# File 'lib/elibri_onix/onix_3_0/title_element.rb', line 29 def to_xml @to_xml end |
Instance Method Details
#full_title ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/elibri_onix/onix_3_0/title_element.rb', line 39 def full_title String.new(self.title.to_s.strip).tap do |_full_title| if _full_title =~ /[\.!\?]$/ #czy kończy się ?!. _full_title << " " + self.subtitle if self.subtitle.present? else _full_title << ". " + self.subtitle if self.subtitle.present? end if self.part_number.present? if self.part_number.to_i.to_s == self.part_number _full_title << " (##{self.part_number})" else _full_title << " (#{self.part_number})" end end end end |