Class: Yarr::AST

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/yarr/ast.rb

Overview

The parsed user input

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ AST

Constructs an AST from a hash produced by the parser


10
11
12
# File 'lib/yarr/ast.rb', line 10

def initialize(hash)
  @hash = stringify_hash_values(hash)
end

Instance Method Details

#[]Object

Accesses an immediate AST sub node by key


20
# File 'lib/yarr/ast.rb', line 20

def_delegator :@hash, :[]

#dig_deep(key) ⇒ Object|nil

Looks up a key traversing the AST recursively


26
27
28
# File 'lib/yarr/ast.rb', line 26

def dig_deep(key)
  self.class.send(:dig_deep, @hash, key)
end

#key?(sym) ⇒ Object

Is the given symbol atthe top level of the AST


20
# File 'lib/yarr/ast.rb', line 20

def_delegator :@hash, :[]