Class: PHP::Node Abstract

Inherits:
Object
  • Object
show all
Includes:
Comparable, Enumerable
Defined in:
lib/php/syntax/node.rb

Overview

This class is abstract.

See Also:

Instance Attribute Summary

Instance Method Summary

Constructor Details

- (Node) initialize(*children)

A new instance of Node

Parameters:

  • (Array<Node>) children


15
16
17
# File 'lib/php/syntax/node.rb', line 15

def initialize(*children)
  @children = children
end

Instance Attribute Details

- (Array<Node>) children

Returns:



11
12
13
# File 'lib/php/syntax/node.rb', line 11

def children
  @children
end

Instance Method Details

- (Node) <<(node)

Appends a new child node to this AST node.

Parameters:

Returns:



42
43
44
45
# File 'lib/php/syntax/node.rb', line 42

def <<(node)
  children << node
  self
end

- (Integer) <=>(other)

This method is abstract.

Compares this AST node to other for sorting purposes.

Returns:

  • (Integer) — -1, 0, 1

Raises:

  • (NotImplementedError)


52
53
54
# File 'lib/php/syntax/node.rb', line 52

def <=>(other)
  raise NotImplementedError
end

- (Boolean) children?

Returns true if this AST node contains any child nodes.

Returns:

  • (Boolean)


23
24
25
# File 'lib/php/syntax/node.rb', line 23

def children?
  @children && @children.size > 0
end

- (Enumerator) each(&block) {|node| ... }

Executes the given block once for each child node of this AST node.

Yields:

  • (node)

Yield Parameters:

Returns:

  • (Enumerator)


33
34
35
# File 'lib/php/syntax/node.rb', line 33

def each(&block)
  children.each(&block)
end

- (Integer) indent

Returns the indentation level for this AST node.

Returns:

  • (Integer)


60
61
62
# File 'lib/php/syntax/node.rb', line 60

def indent
  @indent ||= 0
end

- indent=(value)

This method returns an undefined value.

Defines the indentation level for this AST node.

Parameters:

  • (Integer)


69
70
71
# File 'lib/php/syntax/node.rb', line 69

def indent=(value)
  @indent = value
end

- (String) to_php

This method is abstract.

Returns the PHP representation of this AST node.

Returns:

  • (String)

Raises:

  • (NotImplementedError)


78
79
80
# File 'lib/php/syntax/node.rb', line 78

def to_php
  raise NotImplementedError
end

- (String) to_s

Returns the string representation of this AST node.

Returns:

  • (String)


86
87
88
# File 'lib/php/syntax/node.rb', line 86

def to_s
  to_php
end