Class: Mlc::Abstract::Call

Inherits:
Object
  • Object
show all
Defined in:
lib/mlc/abstract/call.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeCall

Returns a new instance of Call.



6
7
8
# File 'lib/mlc/abstract/call.rb', line 6

def initialize
  @args = []
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



5
6
7
# File 'lib/mlc/abstract/call.rb', line 5

def args
  @args
end

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/mlc/abstract/call.rb', line 4

def name
  @name
end

#objectObject

Returns the value of attribute object.



4
5
6
# File 'lib/mlc/abstract/call.rb', line 4

def object
  @object
end

Instance Method Details

#to_lua(indent, options, state) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/mlc/abstract/call.rb', line 10

def to_lua(indent, options, state)
  obj = @object.to_lua(indent + 1, options, state)
  args = @args.dup.unshift Raw.new('nil')
  name = "m#{@name}"
  if name =~ /^[A-Za-z][A-Za-z0-1_]*$/
    "#{obj}:#{name}#{Mlc.prepare_args(indent, options, state, args)}"
  else
    args.unshift Raw.new("'#{Mlc.escape_str(name)}'")
    "#{obj}:_call#{Mlc.prepare_args(indent, options, state, args)}"
  end
end