Results for: "OptionParser"

OpenTimeout, a subclass of Timeout::Error, is raised if a connection cannot be created within the open_timeout.

The writer adapter class

DesugarCompiler is a compiler that desugars Ruby code into a more primitive form. This is useful for consumers that want to deal with fewer node types.

The dispatcher class fires events for nodes that are found while walking an AST to all registered listeners. It’s useful for performing different types of analysis on the AST while only having to walk the tree once.

To use the dispatcher, you would first instantiate it and register listeners for the events you’re interested in:

class OctalListener
  def on_integer_node_enter(node)
    if node.octal? && !node.slice.start_with?("0o")
      warn("Octal integers should be written with the 0o prefix")
    end
  end
end

dispatcher = Dispatcher.new
dispatcher.register(listener, :on_integer_node_enter)

Then, you can walk any number of trees and dispatch events to the listeners:

result = Prism.parse("001 + 002 + 003")
dispatcher.dispatch(result.value)

Optionally, you can also use ‘#dispatch_once` to dispatch enter and leave events for a single node without recursing further down the tree. This can be useful in circumstances where you want to reuse the listeners you already have registers but want to stop walking the tree at a certain point.

integer = result.value.statements.body.first.receiver.receiver
dispatcher.dispatch_once(integer)

Represents reading a reference to a field in the previous match.

$'
^^

Represents the use of an assignment operator on a call.

foo.bar += baz
^^^^^^^^^^^^^^

Represents referencing a class variable.

@@foo
^^^^^

Represents writing to a class variable in a context that doesn’t have an explicit value.

@@foo, @@bar = baz
^^^^^  ^^^^^

Represents the use of the ‘&&=` operator for assignment to a constant path.

Parent::Child &&= value
^^^^^^^^^^^^^^^^^^^^^^^

Represents accessing a constant through a path of ‘::` operators.

Foo::Bar
^^^^^^^^

Represents the use of the ‘||=` operator for assignment to a constant path.

Parent::Child ||= value
^^^^^^^^^^^^^^^^^^^^^^^

Represents writing to a constant path.

::Foo = 1
^^^^^^^^^

Foo::Bar = 1
^^^^^^^^^^^^

::Foo::Bar = 1
^^^^^^^^^^^^^^

Represents writing to a constant in a context that doesn’t have an explicit value.

Foo, Bar = baz
^^^  ^^^

Represents a find pattern in pattern matching.

foo in *bar, baz, *qux
       ^^^^^^^^^^^^^^^

foo in [*bar, baz, *qux]
       ^^^^^^^^^^^^^^^^^

foo in Foo(*bar, baz, *qux)
       ^^^^^^^^^^^^^^^^^^^^

Represents forwarding all arguments to this method to another method.

def foo(...)
  bar(...)
      ^^^
end

Represents the use of the ‘super` keyword without parentheses or arguments.

super
^^^^^

Represents referencing a global variable.

$foo
^^^^

Represents writing to a global variable in a context that doesn’t have an explicit value.

$foo, $bar = baz
^^^^  ^^^^

Represents a hash pattern in pattern matching.

foo => { a: 1, b: 2 }
       ^^^^^^^^^^^^^^

foo => { a: 1, b: 2, **c }
       ^^^^^^^^^^^^^^^^^^^

Represents the use of an assignment operator on a call to ‘[]`.

foo.bar[baz] += value
^^^^^^^^^^^^^^^^^^^^^

Represents referencing an instance variable.

@foo
^^^^

Represents writing to an instance variable in a context that doesn’t have an explicit value.

@foo, @bar = baz
^^^^  ^^^^

Represents reading a local variable. Note that this requires that a local variable of the same name has already been written to in the same scope, otherwise it is parsed as a method call.

foo
^^^

Represents writing to a local variable in a context that doesn’t have an explicit value.

foo, bar = baz
^^^  ^^^

Represents a multi-target expression.

a, (b, c) = 1, 2, 3
   ^^^^^^
Search took: 9ms  ·  Total Results: 5424