Class: RelatonBib::Series
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_hash ⇒ Hash
- #to_xml(builder) ⇒ Object
Constructor Details
#initialize(**args) ⇒ Series
Returns a new instance of Series.
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/relaton_bib/series.rb', line 52 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]) warn "[relaton-bib] Series type is invalid: #{args[: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)
26 27 28 |
# File 'lib/relaton_bib/series.rb', line 26 def abbreviation @abbreviation end |
#formattedref ⇒ RelatonBib::FormattedRef, NilClass (readonly)
14 15 16 |
# File 'lib/relaton_bib/series.rb', line 14 def formattedref @formattedref end |
#from ⇒ String, NilClass (readonly)
Returns date or year.
29 30 31 |
# File 'lib/relaton_bib/series.rb', line 29 def from @from end |
#number ⇒ String, NilClass (readonly)
35 36 37 |
# File 'lib/relaton_bib/series.rb', line 35 def number @number end |
#organization ⇒ String, NilClass (readonly)
23 24 25 |
# File 'lib/relaton_bib/series.rb', line 23 def organization @organization end |
#partnumber ⇒ String, NilClass (readonly)
38 39 40 |
# File 'lib/relaton_bib/series.rb', line 38 def partnumber @partnumber end |
#place ⇒ String, NilClass (readonly)
20 21 22 |
# File 'lib/relaton_bib/series.rb', line 20 def place @place end |
#title ⇒ RelatonBib::FormattedString, NilClass (readonly)
Returns title.
17 18 19 |
# File 'lib/relaton_bib/series.rb', line 17 def title @title end |
#to ⇒ String, NilClass (readonly)
Returns date or year.
32 33 34 |
# File 'lib/relaton_bib/series.rb', line 32 def to @to end |
#type ⇒ String, NilClass (readonly)
Returns allowed values: “main” or “alt”.
11 12 13 |
# File 'lib/relaton_bib/series.rb', line 11 def type @type end |
Instance Method Details
#to_hash ⇒ Hash
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/relaton_bib/series.rb', line 98 def to_hash hash = {} hash["type"] = type if type hash["formattedref"] = formattedref.to_hash if formattedref hash["title"] = title.to_hash if title hash["place"] = place if place hash["organization"] = organization if organization hash["abbreviation"] = abbreviation.to_hash if abbreviation hash["from"] = from if from hash["to"] = to if to hash["number"] = number if number hash["partnumber"] = partnumber if partnumber hash end |
#to_xml(builder) ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/relaton_bib/series.rb', line 77 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 |