Class: RelatonBib::TypedTitleString
- Inherits:
-
Object
- Object
- RelatonBib::TypedTitleString
- Defined in:
- lib/relaton_bib/typed_title_string.rb
Constant Summary collapse
- TITLE_TYPES =
%w[alternative original unofficial subtitle main].freeze
Instance Attribute Summary collapse
- #title ⇒ RelatonBib::FormattedString readonly
- #type ⇒ String readonly
Instance Method Summary collapse
-
#initialize(**args) ⇒ TypedTitleString
constructor
A new instance of TypedTitleString.
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(**args) ⇒ TypedTitleString
Returns a new instance of TypedTitleString.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/relaton_bib/typed_title_string.rb', line 18 def initialize(**args) if args[:type] && !TITLE_TYPES.include?(args[:type]) raise ArgumentError, %{The type #{args[:type]} is invalid.} end unless args[:title] || args[:content] raise ArgumentError, %{Keyword "title" or "content" should be passed.} end @type = args[:type] if args[:title] @title = args[:title] else fsargs = args.select do |k, _v| %i[content language script format].include? k end @title = FormattedString.new(fsargs) end end |
Instance Attribute Details
#title ⇒ RelatonBib::FormattedString (readonly)
9 10 11 |
# File 'lib/relaton_bib/typed_title_string.rb', line 9 def title @title end |
#type ⇒ String (readonly)
6 7 8 |
# File 'lib/relaton_bib/typed_title_string.rb', line 6 def type @type end |
Instance Method Details
#to_xml(builder) ⇒ Object
41 42 43 44 |
# File 'lib/relaton_bib/typed_title_string.rb', line 41 def to_xml(builder) builder.parent[:type] = type if type title.to_xml builder end |