Class: BOAST::While

Inherits:
ControlStructure show all
Defined in:
lib/BOAST/While.rb

Constant Summary collapse

@@c_strings =
{
  :while => '"while (#{cond}) {"',
  :end => '"}"'
}
@@f_strings =
{
  :while => '"do while (#{cond})"',
  :end => '"end do"'
}
@@strings =
{
  C => @@c_strings,
  CL => @@c_strings,
  CUDA => @@c_strings,
  FORTRAN => @@f_strings
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ControlStructure

inherited, token_string_generator

Methods included from Inspectable

#inspect

Methods included from PrivateStateAccessor

private_boolean_state_accessor, private_state_accessor

Constructor Details

#initialize(condition, &block) ⇒ While

Returns a new instance of While.



7
8
9
10
# File 'lib/BOAST/While.rb', line 7

def initialize(condition, &block)
  @condition = condition
  @block = block
end

Instance Attribute Details

#conditionObject (readonly)

Returns the value of attribute condition.



5
6
7
# File 'lib/BOAST/While.rb', line 5

def condition
  @condition
end

Instance Method Details

#closeObject



54
55
56
57
58
59
60
61
# File 'lib/BOAST/While.rb', line 54

def close
  decrement_indent_level      
  s = ""
  s += indent
  s += end_string
  output.puts s
  return self
end

#openObject



36
37
38
39
40
41
42
43
# File 'lib/BOAST/While.rb', line 36

def open
  s=""
  s += indent
  s += to_s
  output.puts s
  increment_indent_level
  return self
end

#pr(*args) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/BOAST/While.rb', line 45

def pr(*args)
  open
  if @block then
    @block.call(*args)
    close
  end
  return self
end

#to_sObject



32
33
34
# File 'lib/BOAST/While.rb', line 32

def to_s
  return while_string(@condition)
end