Class: Bipm::Data::Importer::Body
- Inherits:
-
Object
- Object
- Bipm::Data::Importer::Body
- Defined in:
- lib/bipm/data/importer/body.rb
Overview
A BIPM committee body (CIPM, CGPM, CCAUV, etc.).
path is locale-agnostic — url(:en) and url(:fr) are constructed
symmetrically by inserting the language segment into the BIPM URL
template. Neither language is canonical; both are first-class.
Constant Summary collapse
- BIPM_ORIGIN =
"https://www.bipm.org".freeze
Instance Attribute Summary collapse
-
#display_name ⇒ Object
readonly
Returns the value of attribute display_name.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#strategy ⇒ Object
readonly
Returns the value of attribute strategy.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean (also: #==)
- #hash ⇒ Object
-
#initialize(id:, display_name:, path:, strategy:) ⇒ Body
constructor
A new instance of Body.
- #to_s ⇒ Object
- #url(language) ⇒ Object
Constructor Details
#initialize(id:, display_name:, path:, strategy:) ⇒ Body
Returns a new instance of Body.
16 17 18 19 20 21 |
# File 'lib/bipm/data/importer/body.rb', line 16 def initialize(id:, display_name:, path:, strategy:) @id = id @display_name = display_name @path = path @strategy = strategy end |
Instance Attribute Details
#display_name ⇒ Object (readonly)
Returns the value of attribute display_name.
14 15 16 |
# File 'lib/bipm/data/importer/body.rb', line 14 def display_name @display_name end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
14 15 16 |
# File 'lib/bipm/data/importer/body.rb', line 14 def id @id end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
14 15 16 |
# File 'lib/bipm/data/importer/body.rb', line 14 def path @path end |
#strategy ⇒ Object (readonly)
Returns the value of attribute strategy.
14 15 16 |
# File 'lib/bipm/data/importer/body.rb', line 14 def strategy @strategy end |
Instance Method Details
#eql?(other) ⇒ Boolean Also known as: ==
28 29 30 |
# File 'lib/bipm/data/importer/body.rb', line 28 def eql?(other) other.is_a?(Body) && @id == other.id end |
#hash ⇒ Object
33 34 35 |
# File 'lib/bipm/data/importer/body.rb', line 33 def hash @id.hash end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/bipm/data/importer/body.rb', line 37 def to_s "#{display_name} (#{id})" end |
#url(language) ⇒ Object
23 24 25 26 |
# File 'lib/bipm/data/importer/body.rb', line 23 def url(language) lang = language.is_a?(Language) ? language : Language.find(language) "#{BIPM_ORIGIN}/#{lang}/#{path}" end |