Class: OpenBD::Title
- Inherits:
-
Object
- Object
- OpenBD::Title
- Defined in:
- lib/open_bd/title.rb
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#initialize(source) ⇒ Title
constructor
A new instance of Title.
- #main_title ⇒ Object
- #sub_title ⇒ Object
- #title ⇒ Object
Constructor Details
#initialize(source) ⇒ Title
Returns a new instance of Title.
5 6 7 |
# File 'lib/open_bd/title.rb', line 5 def initialize(source) @source = source end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
3 4 5 |
# File 'lib/open_bd/title.rb', line 3 def source @source end |
Instance Method Details
#main_title ⇒ Object
17 18 19 |
# File 'lib/open_bd/title.rb', line 17 def main_title source.dig("TitleDetail", "TitleElement", "TitleText", "content") end |
#sub_title ⇒ Object
21 22 23 |
# File 'lib/open_bd/title.rb', line 21 def sub_title source.dig("TitleDetail", "TitleElement", "Subtitle", "content") end |
#title ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/open_bd/title.rb', line 9 def title if sub_title.nil? return main_title end "#{main_title} #{sub_title}" end |