Module: ActionTree

Includes:
Errors
Defined in:
lib/action_tree.rb

Overview

The main ActionTree namespace. Provides convenient shortcuts to common operations. Contains utility classes and dialect modules. For more on dialects, see Basic.

Defined Under Namespace

Modules: Basic, Errors Classes: CaptureHash, EvalScope

Class Method Summary collapse

Class Method Details

.macro(name = nil, &blk) ⇒ Proc

Create an optionally named macro. If a name is given, the macro is remembered by that name, and can later be referenced using ActionTree::Basic::Node#apply.

Returns:

  • (Proc)

    The macro



60
61
62
# File 'lib/action_tree.rb', line 60

def self.macro(name=nil, &blk)
  name ? (MACROS[name] = blk) : blk
end

.new { ... } ⇒ Basic::Node

Create a new Basic ActionTree.

Examples:

a = ActionTree.new do
  action('hi') { "Hello!" }
end
a.match('hi').run #=> "Hello!"

Yields:

  • Constructs the tree from the given block of directives

Returns:

See Also:



53
54
55
# File 'lib/action_tree.rb', line 53

def self.new(&blk)
  Basic.new(&blk)
end