Class: Ec2::ErbProfile

Inherits:
Object
  • Object
show all
Includes:
Helper, Logger
Defined in:
lib/ec2/erb_profile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helper

#error

Methods included from Logger

#debug?, #logger, logger, #stderr, stderr

Constructor Details

#initialize(file, api: nil) ⇒ ErbProfile

Returns a new instance of ErbProfile.



13
14
15
16
# File 'lib/ec2/erb_profile.rb', line 13

def initialize(file, api: nil)
  @file = file
  @api = api
end

Instance Attribute Details

#apiObject

Returns the value of attribute api.



11
12
13
# File 'lib/ec2/erb_profile.rb', line 11

def api
  @api
end

Instance Method Details

#bindingObject



18
19
20
# File 'lib/ec2/erb_profile.rb', line 18

def binding
  api.instance_eval { binding }
end

#renderObject



22
23
24
25
26
27
# File 'lib/ec2/erb_profile.rb', line 22

def render
  erb = ERB.new(File.read(@file), nil, '-')
  erb.result(binding)
rescue => e
  error "while rendering erb file #{@file}"
end