Class: Cmds::ERBContext
- Inherits:
-
BasicObject
- Defined in:
- lib/cmds/erb_context.rb
Instance Method Summary
collapse
Constructor Details
#initialize(args, kwds) ⇒ ERBContext
Returns a new instance of ERBContext.
3
4
5
6
7
|
# File 'lib/cmds/erb_context.rb', line 3
def initialize args, kwds
@args = args
@kwds = kwds
@arg_index = 0
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
# File 'lib/cmds/erb_context.rb', line 9
def method_missing sym, *args, &block
if args.empty? && block.nil?
if sym.to_s[-1] == '?'
key = sym.to_s[0...-1].to_sym
@kwds[key] if @kwds[key]
else
@kwds.fetch sym
end
else
super
end
end
|
Instance Method Details
#arg ⇒ Object
28
29
30
|
# File 'lib/cmds/erb_context.rb', line 28
def arg
@args.fetch(@arg_index).tap {@arg_index += 1}
end
|
#get_binding ⇒ Object
24
25
26
|
# File 'lib/cmds/erb_context.rb', line 24
def get_binding
::Kernel.send :binding
end
|