Class: EacRubyUtils::Templates::VariableProviders::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/eac_ruby_utils/templates/variable_providers/base.rb

Direct Known Subclasses

EntriesReader, Generic, Hash

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source) ⇒ Base

Returns a new instance of Base.


11
12
13
# File 'lib/eac_ruby_utils/templates/variable_providers/base.rb', line 11

def initialize(source)
  @source = source
end

Instance Attribute Details

#sourceObject (readonly)

Returns the value of attribute source


9
10
11
# File 'lib/eac_ruby_utils/templates/variable_providers/base.rb', line 9

def source
  @source
end

Instance Method Details

#variable_value(name) ⇒ Object


15
16
17
18
19
# File 'lib/eac_ruby_utils/templates/variable_providers/base.rb', line 15

def variable_value(name)
  return variable_fetch(name) if variable_exist?(name)

  raise VariableNotFoundError, "Variable \"#{name}\" not found in #{source}"
end