Class: Natsukantou::Env

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/natsukantou/utility/env.rb

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ Env

Returns a new instance of Env.

Parameters:

  • env (Hash)
  • lang_from (Hash)

    a customizable set of options

  • lang_to (Hash)

    a customizable set of options

Options Hash (env):



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/natsukantou/utility/env.rb', line 14

def initialize(env)
  # Convert languages
  [:lang_from, :lang_to].each do |key|
    lang = env.fetch(key)
    next if lang.is_a?(LanguageCode)

    env[key] = LanguageCode.new(lang)
  end

  # Required keys
  [:dom].each do |key|
    env.fetch(key)
  end

  super(env)
end

Instance Method Details

#domObject



31
32
33
# File 'lib/natsukantou/utility/env.rb', line 31

def dom
  self[:dom]
end

#lang_fromObject



35
36
37
# File 'lib/natsukantou/utility/env.rb', line 35

def lang_from
  self[:lang_from]
end

#lang_toObject



39
40
41
# File 'lib/natsukantou/utility/env.rb', line 39

def lang_to
  self[:lang_to]
end