Class: Elibri::ONIX::Release_3_0::TitleElement
- Inherits:
-
Object
- Object
- Elibri::ONIX::Release_3_0::TitleElement
- Defined in:
- lib/elibri_onix/onix_3_0/title_element.rb
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.
Constructor Details
#initialize(data) ⇒ TitleElement
Returns a new instance of TitleElement.
8 9 10 11 12 13 14 |
# File 'lib/elibri_onix/onix_3_0/title_element.rb', line 8 def initialize(data) @to_xml = data.to_s @level = data.at_css('TitleElementLevel')&.text @part_number = data.at_css('PartNumber')&.text @title = data.at_css('TitleText')&.text @subtitle = data.at_css('Subtitle')&.text end |
Instance Attribute Details
#level ⇒ Object
Returns the value of attribute level.
6 7 8 |
# File 'lib/elibri_onix/onix_3_0/title_element.rb', line 6 def level @level end |
#part_number ⇒ Object
Returns the value of attribute part_number.
6 7 8 |
# File 'lib/elibri_onix/onix_3_0/title_element.rb', line 6 def part_number @part_number end |
#subtitle ⇒ Object
Returns the value of attribute subtitle.
6 7 8 |
# File 'lib/elibri_onix/onix_3_0/title_element.rb', line 6 def subtitle @subtitle end |
#title ⇒ Object
Returns the value of attribute title.
6 7 8 |
# File 'lib/elibri_onix/onix_3_0/title_element.rb', line 6 def title @title end |
#to_xml ⇒ Object
Returns the value of attribute to_xml.
6 7 8 |
# File 'lib/elibri_onix/onix_3_0/title_element.rb', line 6 def to_xml @to_xml end |
Instance Method Details
#full_title ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/elibri_onix/onix_3_0/title_element.rb', line 16 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 && self.subtitle.size > 0 else _full_title << ". " + self.subtitle if self.subtitle && self.subtitle.size > 0 end if self.part_number && self.part_number.size > 0 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 |