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

# class Ameba::AST::Branch

- Ameba::AST::Branch
- Reference
- Object

##
Overview

Represents the branch in Crystal code. Branch is a part of a branchable statement. For example, the branchable if statement contains 3 branches:

    if a = something # --> Branch A
      a = 1          # --> Branch B
      put a if out   # --> Branch C
    else
      do_something a # --> Branch D
    end

##
Defined in:

ameba/ast/branch.cr

##
Constructors

- .new(node : Crystal::ASTNode, parent : Ameba::AST::Branchable)

  Creates a new branch.

##
Class Method Summary

- .of(node : Crystal::ASTNode, parent_node : Crystal::ASTNode)

  Constructs a new branch based on the node some parent scope.

- .of(node : Crystal::ASTNode, scope : Scope)

  Constructs a new branch based on the node in scope.

##
Instance Method Summary

- #==(other : self)

  Returns `true` if this reference is the same as other.

- #end_location(*args, **options)
- #end_location(*args, **options, &)
- #hash(hasher)

  See `Object#hash(hasher)`

- #in_loop?

  Returns `true` if current branch is in a loop, `false` - otherwise.

- #location(*args, **options)
- #location(*args, **options, &)
- #node : Crystal::ASTNode

  The actual branch node.

- #parent : Branchable

  The parent branchable.

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

##
Constructor Detail

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

Creates a new branch.

    Branch.new(if_node)

##
Class Method Detail

def self.of(node : Crystal::ASTNode, parent_node : Crystal::ASTNode) #

Constructs a new branch based on the node some parent scope.

    Branch.of(assign_node, def_node)

def self.of(node : Crystal::ASTNode, scope : Scope) #

Constructs a new branch based on the node in scope.

    Branch.of(assign_node, scope)

##
Instance Method Detail

def ==(other : self) #
Description copied from class Reference

Returns `true` if this reference is the same as other. Invokes `same?`.

def end_location(*args, **options) #
def end_location(*args, **options, &) #
def hash(hasher) #
Description copied from class Reference

See `Object#hash(hasher)`

def in_loop? #

Returns `true` if current branch is in a loop, `false` - otherwise. For example, this branch is in a loop:

    while true
      handle_input # this branch is in a loop
      if wrong_input
        show_message # this branch is also in a loop.
      end
    end

def location(*args, **options) #
def location(*args, **options, &) #
def node : Crystal::ASTNode #

The actual branch node.

def parent : Branchable #

The parent branchable.

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