Class: Lasp::Fn

Inherits:
Object
  • Object
show all
Defined in:
lib/lasp/fn.rb

Direct Known Subclasses

Macro

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#bodyObject (readonly)

Returns the value of attribute body.



7
8
9
# File 'lib/lasp/fn.rb', line 7

def body
  @body
end

#envObject (readonly)

Returns the value of attribute env.



7
8
9
# File 'lib/lasp/fn.rb', line 7

def env
  @env
end

#paramsObject (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

#inspectObject



19
20
21
22
# File 'lib/lasp/fn.rb', line 19

def inspect
  class_name = self.class.name.split("::").last
  "#<#{class_name} #{params}>"
end