Class: KnowsAboutTheEnvironment::EnvStruct

Inherits:
Object
  • Object
show all
Defined in:
lib/cucumber/blinkbox/environment.rb

Instance Method Summary collapse

Constructor Details

#initialize(env) ⇒ EnvStruct

Returns a new instance of EnvStruct.


5
6
7
# File 'lib/cucumber/blinkbox/environment.rb', line 5

def initialize(env)
  @env = env
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args) ⇒ Object


12
13
14
15
# File 'lib/cucumber/blinkbox/environment.rb', line 12

def method_missing(name, *args)
  key = name.to_s.tr("_", " ").downcase
  self[key]
end

Instance Method Details

#[](key) ⇒ Object


8
9
10
11
# File 'lib/cucumber/blinkbox/environment.rb', line 8

def [](key)
  value = @env[key.to_s]
  value.is_a?(Hash) ? EnvStruct.new(value) : value
end

#inspectObject


16
17
18
# File 'lib/cucumber/blinkbox/environment.rb', line 16

def inspect
  @env.inspect
end