Class: Bipm::Data::Importer::Body

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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_nameObject (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

#idObject (readonly)

Returns the value of attribute id.



14
15
16
# File 'lib/bipm/data/importer/body.rb', line 14

def id
  @id
end

#pathObject (readonly)

Returns the value of attribute path.



14
15
16
# File 'lib/bipm/data/importer/body.rb', line 14

def path
  @path
end

#strategyObject (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: ==

Returns:

  • (Boolean)


28
29
30
# File 'lib/bipm/data/importer/body.rb', line 28

def eql?(other)
  other.is_a?(Body) && @id == other.id
end

#hashObject



33
34
35
# File 'lib/bipm/data/importer/body.rb', line 33

def hash
  @id.hash
end

#to_sObject



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