Class: Rampi::Func

Inherits:
Node
  • Object
show all
Defined in:
lib/rampi/node.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#!=, #%, #&, #*, #**, #+, #-, #-@, #/, #<, #<<, #<=, #==, #>, #>=, #>>, #^, #|, #~

Constructor Details

#initialize(name, *args, **kwargs) ⇒ Func

Returns a new instance of Func.



65
66
67
68
69
# File 'lib/rampi/node.rb', line 65

def initialize(name, *args, **kwargs)
  @name = name
  @args = args
  @kwargs = kwargs
end

Instance Attribute Details

#argsObject

Returns the value of attribute args.



63
64
65
# File 'lib/rampi/node.rb', line 63

def args
  @args
end

#kwargsObject

Returns the value of attribute kwargs.



63
64
65
# File 'lib/rampi/node.rb', line 63

def kwargs
  @kwargs
end

#nameObject

Returns the value of attribute name.



63
64
65
# File 'lib/rampi/node.rb', line 63

def name
  @name
end

Instance Method Details

#accept(visitor) ⇒ Object



78
79
80
# File 'lib/rampi/node.rb', line 78

def accept(visitor)
  visitor.visit_func(self)
end

#to_sObject Also known as: inspect



71
72
73
74
75
# File 'lib/rampi/node.rb', line 71

def to_s
  kwargs_s = @kwargs.map { |k, v| "#{k}: #{v}" }.join(', ')
  args_s = @args.join(', ')
  "#{@name}(#{args_s}#{!kwargs_s.empty? ? ", #{kwargs_s}" : ''})"
end