Class: PHP::Program

Inherits:
PHP::Node show all
Defined in:
lib/php/syntax/program.rb

Overview

See Also:

Instance Method Summary

Methods inherited from PHP::Node

#<=>, #children?, #each, #indent, #indent=, #to_s

Constructor Details

- (Program) initialize(*statements)

A new instance of Program

Parameters:



7
8
9
# File 'lib/php/syntax/program.rb', line 7

def initialize(*statements)
  @children = statements
end

Instance Method Details

- (Program) <<(statement)

Appends a new statement to this program.

Parameters:

Returns:



24
25
26
# File 'lib/php/syntax/program.rb', line 24

def <<(statement)
  super
end

- (Array<Statement>) statements

Returns the statements that constitute this program.

Returns:



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

def statements
  @children
end

- (String) to_php

Returns the PHP representation of this program.

Returns:

  • (String)


32
33
34
# File 'lib/php/syntax/program.rb', line 32

def to_php
  "<?php\n" << statements.map(&:to_php).join("\n") << (children? ? ";\n" : '')
end