Module: Ruby

Includes:
Conversions
Defined in:
lib/ruby.rb,
lib/ruby/if.rb,
lib/ruby/for.rb,
lib/ruby/args.rb,
lib/ruby/call.rb,
lib/ruby/case.rb,
lib/ruby/hash.rb,
lib/ruby/list.rb,
lib/ruby/node.rb,
lib/ruby/array.rb,
lib/ruby/assoc.rb,
lib/ruby/block.rb,
lib/ruby/const.rb,
lib/ruby/token.rb,
lib/ruby/while.rb,
lib/ruby/method.rb,
lib/ruby/params.rb,
lib/ruby/string.rb,
lib/ruby/symbol.rb,
lib/ruby/literal.rb,
lib/ruby/operator.rb,
lib/ruby/aggregate.rb,
lib/ruby/node/text.rb,
lib/ruby/assignment.rb,
lib/ruby/statements.rb,
lib/ruby/node/source.rb,
lib/ruby/node/position.rb,
lib/ruby/node/composite.rb,
lib/ruby/node/traversal.rb,
lib/ruby/alternation/args.rb,
lib/ruby/alternation/hash.rb,
lib/ruby/alternation/list.rb,
lib/ruby/node/conversions.rb

Overview

Object oriented representation of Ruby code.

The base class is Ruby::Node. It facilitates

* a composite pattern (see Ruby::Node::Composite)
* means for extracting from the original source (see Ruby::Node::Source)

There are two main concrete classes derived from Node: Token and Aggregate.

Tokens are “atomic” node types that represent non-composite Ruby constructs such as Keyword, Identifier, StringContent and literal types such as integers, floats, true, false, nil etc. Aggregates are composed node types that hold one or many tokens, such as Class, Module, Block, If, For, Case, While etc.

Each node type supports the to_ruby method which will return an exact copy of the orginal code it was parsed from.

There are also a few helper methods for converting a node to another type (see Ruby::Node::Conversions) and very few helper methods for altering existing code structures (see Ruby::Alternation).

Defined Under Namespace

Modules: Alternation, Conversions Classes: Aggregate, Alias, Arg, ArgsList, Array, Assignment, Assoc, Binary, Block, Call, Case, ChainedBlock, Char, Class, Const, DelimitedAggregate, DelimitedList, DelimitedVariable, DynaSymbol, Else, ExecutableString, False, Float, For, Hash, Heredoc, HeredocBegin, Identifier, If, IfMod, IfOp, Integer, Keyword, Label, List, Method, Module, MultiAssignment, NamedAggregate, NamedBlock, Nil, Node, Operator, Param, Params, Program, Prolog, Range, Regexp, RescueMod, RescueParams, Statements, String, StringConcat, StringContent, Symbol, Token, True, Unary, Unless, UnlessMod, Until, UntilMod, Variable, When, While, WhileMod, Whitespace

Method Summary

Methods included from Conversions

included, #to_node