Class: RelatonBib::Series
- Inherits:
-
Object
- Object
- RelatonBib::Series
- Defined in:
- lib/relaton_bib/series.rb
Overview
Series class.
Constant Summary collapse
- TYPES =
%w[main alt].freeze
Instance Attribute Summary collapse
- #abbreviation ⇒ RelatonBib::LocalizedString, NilClass readonly
- #formattedref ⇒ RelatonBib::FormattedRef, NilClass readonly
-
#from ⇒ String, NilClass
readonly
Date or year.
- #number ⇒ String, NilClass readonly
- #organization ⇒ String, NilClass readonly
- #partnumber ⇒ String, NilClass readonly
- #place ⇒ String, NilClass readonly
-
#title ⇒ RelatonBib::FormattedString, NilClass
readonly
Title.
-
#to ⇒ String, NilClass
readonly
Date or year.
-
#type ⇒ String, NilClass
readonly
Allowed values: “main” or “alt”.
Instance Method Summary collapse
-
#initialize(**args) ⇒ Series
constructor
A new instance of Series.
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(**args) ⇒ Series
Returns a new instance of Series.
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/relaton_bib/series.rb', line 67 def initialize(**args) unless args[:title].is_a?(RelatonBib::TypedTitleString) || args[:formattedref] raise ArgumentError, "argument `title` or `formattedref` should present" end if args[:type] && !TYPES.include?(args[:type]) raise ArgumentError, "invalid argument `type`" end @type = args[:type] # if %w[main alt].include? args[:type] @title = args[:title] @formattedref = args[:formattedref] @place = args[:place] @organization = args[:organization] @abbreviation = args[:abbreviation] @from = args[:from] @to = args[:to] @number = args[:number] @partnumber = args[:partnumber] end |
Instance Attribute Details
#abbreviation ⇒ RelatonBib::LocalizedString, NilClass (readonly)
41 42 43 |
# File 'lib/relaton_bib/series.rb', line 41 def abbreviation @abbreviation end |
#formattedref ⇒ RelatonBib::FormattedRef, NilClass (readonly)
29 30 31 |
# File 'lib/relaton_bib/series.rb', line 29 def formattedref @formattedref end |
#from ⇒ String, NilClass (readonly)
Returns date or year.
44 45 46 |
# File 'lib/relaton_bib/series.rb', line 44 def from @from end |
#number ⇒ String, NilClass (readonly)
50 51 52 |
# File 'lib/relaton_bib/series.rb', line 50 def number @number end |
#organization ⇒ String, NilClass (readonly)
38 39 40 |
# File 'lib/relaton_bib/series.rb', line 38 def organization @organization end |
#partnumber ⇒ String, NilClass (readonly)
53 54 55 |
# File 'lib/relaton_bib/series.rb', line 53 def partnumber @partnumber end |
#place ⇒ String, NilClass (readonly)
35 36 37 |
# File 'lib/relaton_bib/series.rb', line 35 def place @place end |
#title ⇒ RelatonBib::FormattedString, NilClass (readonly)
Returns title.
32 33 34 |
# File 'lib/relaton_bib/series.rb', line 32 def title @title end |
#to ⇒ String, NilClass (readonly)
Returns date or year.
47 48 49 |
# File 'lib/relaton_bib/series.rb', line 47 def to @to end |
#type ⇒ String, NilClass (readonly)
Returns allowed values: “main” or “alt”.
26 27 28 |
# File 'lib/relaton_bib/series.rb', line 26 def type @type end |
Instance Method Details
#to_xml(builder) ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/relaton_bib/series.rb', line 92 def to_xml(builder) xml = builder.series do if formattedref formattedref.to_xml builder else builder.title { title.to_xml builder } builder.place place if place builder.organization organization if organization builder.abbreviation { abbreviation.to_xml builder } if abbreviation builder.from from if from builder.to to if to builder.number number if number builder.partnumber partnumber if partnumber end end xml[:type] = type if type end |