Ameba::AST::Branchable - ameba 1.6.4-1-dev

# class Ameba::AST::Branchable

- Ameba::AST::Branchable
- Reference
- Object

##
Overview

A generic entity to represent a branchable Crystal node. For example, `Crystal::If`, `Crystal::Unless`, `Crystal::While` are branchables.

    while a > 100 # Branchable A
      if b > 2    # Branchable B
        a += 1
      end
    end

##
Included Modules

- Ameba::AST::Util

##
Defined in:

ameba/ast/branchable.cr

##
Constructors

- .new(node : Crystal::ASTNode, parent : Nil | Ameba::AST::Branchable = nil)

  Creates a new branchable

##
Instance Method Summary

- #branches : Array(Crystal::ASTNode)

  Array of branches

- #end_location(*args, **options)
- #end_location(*args, **options, &)
- #location(*args, **options)
- #location(*args, **options, &)
- #loop?

  Returns `true` if this node or one of the parent branchables is a loop, `false` otherwise.

- #node : Crystal::ASTNode

  The actual Crystal node

- #parent : Branchable | Nil

  Parent branchable (if any)

- #to_s(*args, **options)
- #to_s(*args, **options, &)

### Instance methods inherited from module `Ameba::AST::Util`

abort?(node) abort?, control_exp_code(node : Crystal::ControlExpression, code_lines) control_exp_code, dynamic_literal?(node) : Bool dynamic_literal?, exit?(node) exit?, flow_command?(node, in_loop) flow_command?, flow_expression?(node, in_loop = false) flow_expression?, literal?(node) : Bool literal?, loop?(node) loop?, name_end_location(node) name_end_location, name_location(node) name_location, name_size(node) name_size, node_source(node, code_lines) node_source, path_named?(node, name) : Bool path_named?, raise?(node) raise?, source_between(loc, end_loc, code_lines) : String | Nil source_between, static_literal?(node) : Bool static_literal?

##
Constructor Detail

def self.new(node : Crystal::ASTNode, parent : Nil | Ameba::AST::Branchable = nil) #

Creates a new branchable

    Branchable.new(node, parent_branchable)

##
Instance Method Detail

def branches : Array(Crystal::ASTNode) #

Array of branches

def end_location(*args, **options) #
def end_location(*args, **options, &) #
def location(*args, **options) #
def location(*args, **options, &) #
def loop? #

Returns `true` if this node or one of the parent branchables is a loop, `false` otherwise.

def node : Crystal::ASTNode #

The actual Crystal node

def parent : Branchable | Nil #

Parent branchable (if any)

def to_s(*args, **options) #
def to_s(*args, **options, &) #