Class: Prism::Scope

Inherits:
Object
  • Object
show all
Defined in:
lib/prism/parse_result.rb,
sig/generated/prism/parse_result.rbs,
ext/prism/extension.c

Overview

This object is passed to the various Prism.* methods that accept the scopes option as an element of the list. It defines both the local variables visible at that scope as well as the forwarding parameters available at that scope.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(locals, forwarding) ⇒ Scope

Create a new scope object with the given locals and forwarding.

: (Array locals, Array forwarding) -> void

Parameters:

  • locals (Array[Symbol])
  • forwarding (Array[Symbol])


1222
1223
1224
1225
# File 'lib/prism/parse_result.rb', line 1222

def initialize(locals, forwarding)
  @locals = locals
  @forwarding = forwarding
end

Instance Attribute Details

#forwarding ⇒ Array[Symbol] (readonly)

The list of local variables that are forwarded to the next scope. This should by defined as an array of symbols containing the specific values of :*, :**, :&, or :"...".

Returns:

  • (Array[Symbol])


1217
1218
1219
# File 'lib/prism/parse_result.rb', line 1217

def forwarding
  @forwarding
end

#locals ⇒ Array[Symbol] (readonly)

The list of local variables that are defined in this scope. This should be defined as an array of symbols.

Returns:

  • (Array[Symbol])


1212
1213
1214
# File 'lib/prism/parse_result.rb', line 1212

def locals
  @locals
end