Class: Bipm::Data::Outcomes::Body

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/bipm/data/outcomes/body.rb

Direct Known Subclasses

LocalizedBody

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body, locale = nil) ⇒ Body

Returns a new instance of Body.



5
6
7
# File 'lib/bipm/data/outcomes/body.rb', line 5

def initialize(body, locale = nil)
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



9
10
11
# File 'lib/bipm/data/outcomes/body.rb', line 9

def body
  @body
end

Instance Method Details

#each(&block) ⇒ Object



25
26
27
# File 'lib/bipm/data/outcomes/body.rb', line 25

def each(&block)
  locales.values.each(&block)
end

#file_pathObject



11
12
13
# File 'lib/bipm/data/outcomes/body.rb', line 11

def file_path
  "#{Outcomes.file_path}#{@body}/"
end

#locale(name) ⇒ Object Also known as: []



16
17
18
# File 'lib/bipm/data/outcomes/body.rb', line 16

def locale(name)
  LocalizedBody.new(@body, name)
end

#localesObject



21
22
23
# File 'lib/bipm/data/outcomes/body.rb', line 21

def locales
  %i[fr en].to_h { |name| [name, locale(name)] }
end