Class: PHP::Loop::While

Inherits:
PHP::Loop show all
Defined in:
lib/php/syntax/loop.rb

Overview

See Also:

Instance Attribute Summary

Instance Method Summary

Methods inherited from PHP::Node

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

Constructor Details

- (While) initialize(condition, *body)

A new instance of While

Parameters:



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

def initialize(condition, *body)
  @condition = condition
  @children  = body.map { |exp| Block.for(exp) }
end

Instance Attribute Details

- (Expression) condition

Returns:



10
11
12
# File 'lib/php/syntax/loop.rb', line 10

def condition
  @condition
end

Instance Method Details

- (String) to_php

Returns the PHP representation of this while loop.

Returns:

  • (String)


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

def to_php
  body = children.map(&:to_php).join('; ')
  "while (#{condition}) { #{body} }" # FIXME
end