Sha256: 87e3acbf5dd466e198287357637597840413a8fae0f9d5b2dba35e51e475a5e7

Contents?: true

Size: 1.47 KB

Versions: 1

Compression:

Stored size: 1.47 KB

Contents

#
#           \/ |    |/
#        \/ / \||/  /_/___/_
#         \/   |/ \/
#    _\__\_\   |  /_____/_
#           \  | /          /
#  __ _-----`  |{,-----------~
#            \ }{
#             }{{
#             }}{       ActionTree (c) 2011
#             {{}       Jostein Berre Eliassen
#       , -=-~{ .-^- _
#  ejm        `}
#              {
#

require 'set'
require 'backports'

# The main ActionTree namespace. Provides convenient
# shortcuts to common operations. Contains utility classes
# and dialect modules. For more on dialects, see {Basic}.
# 
# @see https://github.com/jbe/action_tree/wiki The ActionTree Wiki

module ActionTree

  require 'action_tree/eval_scope'
  require 'action_tree/capture_hash'
  require 'action_tree/errors'
  require 'action_tree/basic'

  include Errors

  # @private
  # Named procs that can be applied to trees.
  MACROS = {}

  # Create a new {Basic} ActionTree.
  #
  # @yield Constructs the tree from the given block of directives
  #
  # @example
  #   a = ActionTree.new do
  #     action('hi') { "Hello!" }
  #   end
  #   a.match('hi').run #=> "Hello!"
  #
  # @see Basic::Node
  #
  # @return [Basic::Node] Root node of the created tree
  def self.new(&blk)
    Basic.new(&blk)
  end

  # Create an optionally named macro. If a name is given, the macro is remembered by that name, and can later be referenced using {Basic::Node#apply}.
  #
  # @return [Proc] The macro
  def self.macro(name=nil, &blk)
    name ? (MACROS[name] = blk) : blk
  end

end


Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
action_tree-0.2.0 lib/action_tree.rb