Class: HCL::ASTVisitor

Inherits:
Object show all
Defined in:
lib/hcl/ast_visitor.rb

Direct Known Subclasses

Decoder

Constant Summary collapse

@@types =
[
  :document,
  :kv_key,
  :string,
  :key_string,
  :object,
  :comment,
  :integer,
  :boolean,
  :float,
  :heredoc,
  :list,
  :object
]

Instance Method Summary collapse

Instance Method Details

#visit(ast) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
# File 'lib/hcl/ast_visitor.rb', line 17

def visit(ast)
  return nil unless ast

  raise "AST object must be Hash" unless Hash === ast

  type = @@types.find { |type| ast.key? type }
  raise "Couldn't determine AST object type" unless type

  method_name = "visit_#{type}"
  send(method_name, ast)
end