Class: Rebi::ErbHelper

Inherits:
Object
  • Object
show all
Defined in:
lib/rebi/erb_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(input, env_conf) ⇒ ErbHelper

Returns a new instance of ErbHelper.



3
4
5
6
7
# File 'lib/rebi/erb_helper.rb', line 3

def initialize input, env_conf
  @input = input
  @env = env_conf.environment_variables || {}
  @options = env_conf.options
end

Instance Method Details

#rebiObject



13
14
15
16
17
18
19
# File 'lib/rebi/erb_helper.rb', line 13

def rebi
  OpenStruct.new ({
    env: @env,
    opts: @options,
    options: @options,
    })
end

#rebi_env(k = nil) ⇒ Object



9
10
11
# File 'lib/rebi/erb_helper.rb', line 9

def rebi_env k=nil
  k.present? ? @env[k] : @env
end

#resultObject



21
22
23
# File 'lib/rebi/erb_helper.rb', line 21

def result
  ERB.new(@input).result(binding)
end