Class: Lasp::Fn
- Inherits:
-
Object
- Object
- Lasp::Fn
- Defined in:
- lib/lasp/fn.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
Instance Method Summary collapse
- #call(*args) ⇒ Object
-
#initialize(params, body, env) ⇒ Fn
constructor
A new instance of Fn.
- #inspect ⇒ Object
Constructor Details
#initialize(params, body, env) ⇒ Fn
Returns a new instance of Fn.
9 10 11 12 13 |
# File 'lib/lasp/fn.rb', line 9 def initialize(params, body, env) @params = Params.new(params) @body = body @env = env end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
7 8 9 |
# File 'lib/lasp/fn.rb', line 7 def body @body end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
7 8 9 |
# File 'lib/lasp/fn.rb', line 7 def env @env end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
7 8 9 |
# File 'lib/lasp/fn.rb', line 7 def params @params end |
Instance Method Details
#call(*args) ⇒ Object
15 16 17 |
# File 'lib/lasp/fn.rb', line 15 def call(*args) Interpreter.eval(body, env_with_args(args)) end |
#inspect ⇒ Object
19 20 21 22 |
# File 'lib/lasp/fn.rb', line 19 def inspect class_name = self.class.name.split("::").last "#<#{class_name} #{params}>" end |