Class: Crisp::Function
- Inherits:
-
Object
- Object
- Crisp::Function
- Defined in:
- lib/crisp/function.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #bind(name, env) ⇒ Object
- #eval(env, params = []) ⇒ Object
-
#initialize(&blk) ⇒ Function
constructor
A new instance of Function.
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
#name ⇒ Object (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 |