Class: Scribble::Nodes::Call

Inherits:
Node
  • Object
show all
Defined in:
lib/scribble/nodes/call.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#slice

Instance Method Summary collapse

Methods inherited from Node

#line_and_column

Constructor Details

#initialize(slice, name, args: [], receiver: nil, allow_variable: false) ⇒ Call

Returns a new instance of Call.



8
9
10
11
# File 'lib/scribble/nodes/call.rb', line 8

def initialize slice, name, args: [], receiver: nil, allow_variable: false
  super slice
  @name, @args, @receiver, @allow_variable = name, args, receiver, allow_variable
end

Instance Attribute Details

#allow_variableObject (readonly)

Returns the value of attribute allow_variable.



4
5
6
# File 'lib/scribble/nodes/call.rb', line 4

def allow_variable
  @allow_variable
end

#argsObject (readonly)

Returns the value of attribute args.



4
5
6
# File 'lib/scribble/nodes/call.rb', line 4

def args
  @args
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/scribble/nodes/call.rb', line 4

def name
  @name
end

#nodesObject

Returns the value of attribute nodes.



6
7
8
# File 'lib/scribble/nodes/call.rb', line 6

def nodes
  @nodes
end

#receiverObject

Returns the value of attribute receiver.



6
7
8
# File 'lib/scribble/nodes/call.rb', line 6

def receiver
  @receiver
end

Instance Method Details

#block?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/scribble/nodes/call.rb', line 28

def block?
  Registry.block? name
end

#evaluate(context, allow_block: true, allow_split: false) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/scribble/nodes/call.rb', line 13

def evaluate context, allow_block: true, allow_split: false
  disallow_split unless allow_split
  disallow_block unless allow_block

  if @receiver
    Registry.evaluate @name, evaluated_receiver(context), evaluated_args(context), self, context
  else
    context.evaluate self, evaluated_args(context), context
  end
rescue Errors::UnlocatedArgument => e
  raise Errors::Argument.new("#{e.message} #{line_and_column}")
rescue Support::Unmatched => e
  raise e.to_error self
end

#split?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/scribble/nodes/call.rb', line 32

def split?
  Registry.split? name
end