Class: RelatonBib::Place::RegionType
Instance Attribute Summary collapse
-
#iso ⇒ Strign?
readonly
ISO code of region.
-
#name ⇒ Strign
readonly
Name of region.
-
#recommended ⇒ Boolean?
readonly
<description>.
Instance Method Summary collapse
-
#initialize(name:, iso: nil, recommended: nil) ⇒ RegionType
constructor
Initialize region type.
-
#to_asciibib(pref, count = 1) ⇒ String
Render region type as AsciiBib.
-
#to_hash ⇒ Hash
Render region type as Hash.
-
#to_xml(builder) ⇒ Object
Render region type as XML.
Constructor Details
#initialize(name:, iso: nil, recommended: nil) ⇒ RegionType
Initialize region type.
95 96 97 98 99 |
# File 'lib/relaton_bib/place.rb', line 95 def initialize(name:, iso: nil, recommended: nil) @name = name @iso = iso @recommended = recommended end |
Instance Attribute Details
#iso ⇒ Strign? (readonly)
Returns ISO code of region.
83 84 85 |
# File 'lib/relaton_bib/place.rb', line 83 def iso @iso end |
#name ⇒ Strign (readonly)
Returns name of region.
80 81 82 |
# File 'lib/relaton_bib/place.rb', line 80 def name @name end |
#recommended ⇒ Boolean? (readonly)
Returns <description>.
86 87 88 |
# File 'lib/relaton_bib/place.rb', line 86 def recommended @recommended end |
Instance Method Details
#to_asciibib(pref, count = 1) ⇒ String
Render region type as AsciiBib.
132 133 134 135 136 137 138 |
# File 'lib/relaton_bib/place.rb', line 132 def to_asciibib(pref, count = 1) # rubocop:disable Metrics/AbcSize out = count > 1 ? "#{pref}::\n" : "" out += "#{pref}.name:: #{name}\n" out += "#{pref}.iso:: #{iso}\n" if iso out += "#{pref}.recommended:: #{recommended}\n" if recommended out end |
#to_hash ⇒ Hash
Render region type as Hash.
117 118 119 120 121 122 |
# File 'lib/relaton_bib/place.rb', line 117 def to_hash hash = { "name" => name } hash["iso"] = iso if iso hash["recommended"] = recommended unless recommended.nil? hash end |
#to_xml(builder) ⇒ Object
Render region type as XML.
106 107 108 109 110 |
# File 'lib/relaton_bib/place.rb', line 106 def to_xml(builder) builder.parent["iso"] = iso if iso builder.parent["recommended"] = recommended.to_s unless recommended.nil? builder.text name end |