Class: Crisp::Function

Inherits:
Object
  • Object
show all
Defined in:
lib/crisp/function.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(&blk) ⇒ Function

Returns a new instance of Function.



5
6
7
8
# File 'lib/crisp/function.rb', line 5

def initialize(&blk)
  @name = nil
  @blk = blk
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/crisp/function.rb', line 3

def name
  @name
end

Instance Method Details

#bind(name, env) ⇒ Object



10
11
12
13
# File 'lib/crisp/function.rb', line 10

def bind(name, env)
  @name = name.to_sym
  env[name] = self
end

#eval(env, params = []) ⇒ Object



15
16
17
18
19
# File 'lib/crisp/function.rb', line 15

def eval(env, params = [])
  @env = env
  @params = params
  self.instance_eval(&@blk)
end