Class: BOAST::While
Instance Attribute Summary collapse
-
#condition ⇒ Object
readonly
Returns the value of attribute condition.
Class Method Summary collapse
Instance Method Summary collapse
- #close(final = true) ⇒ Object
- #close_c(final = true) ⇒ Object
- #close_fortran(final = true) ⇒ Object
-
#initialize(condition, &block) ⇒ While
constructor
A new instance of While.
- #print(*args) ⇒ Object
- #to_s ⇒ Object
- #to_str ⇒ Object
- #to_str_c ⇒ Object
- #to_str_fortran ⇒ Object
Constructor Details
#initialize(condition, &block) ⇒ While
Returns a new instance of While.
1358 1359 1360 1361 |
# File 'lib/BOAST/Algorithm.rb', line 1358 def initialize(condition, &block) @condition = condition @block = block end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
1357 1358 1359 |
# File 'lib/BOAST/Algorithm.rb', line 1357 def condition @condition end |
Class Method Details
.parens(*args, &block) ⇒ Object
1353 1354 1355 |
# File 'lib/BOAST/Algorithm.rb', line 1353 def self.parens(*args,&block) return self::new(*args,&block) end |
Instance Method Details
#close(final = true) ⇒ Object
1393 1394 1395 1396 |
# File 'lib/BOAST/Algorithm.rb', line 1393 def close(final=true) return self.close_fortran(final) if BOAST::get_lang == FORTRAN return self.close_c(final) if [C, CL, CUDA].include?( BOAST::get_lang ) end |
#close_c(final = true) ⇒ Object
1397 1398 1399 1400 1401 1402 1403 1404 |
# File 'lib/BOAST/Algorithm.rb', line 1397 def close_c(final=true) s = "" BOAST::decrement_indent_level s += " "*BOAST::get_indent_level if final s += "}" BOAST::get_output.puts s if final return s end |
#close_fortran(final = true) ⇒ Object
1405 1406 1407 1408 1409 1410 1411 1412 |
# File 'lib/BOAST/Algorithm.rb', line 1405 def close_fortran(final=true) s = "" BOAST::decrement_indent_level s += " "*BOAST::get_indent_level if final s += "end do" BOAST::get_output.puts s if final return s end |
#print(*args) ⇒ Object
1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 |
# File 'lib/BOAST/Algorithm.rb', line 1379 def print(*args) final = true s="" s += " "*BOAST::get_indent_level if final s += self.to_str BOAST::increment_indent_level BOAST::get_output.puts s if final if @block then s += "\n" @block.call(*args) s += self.close end return s end |
#to_s ⇒ Object
1362 1363 1364 |
# File 'lib/BOAST/Algorithm.rb', line 1362 def to_s self.to_str end |
#to_str ⇒ Object
1365 1366 1367 1368 |
# File 'lib/BOAST/Algorithm.rb', line 1365 def to_str return self.to_str_fortran if BOAST::get_lang == FORTRAN return self.to_str_c if [C, CL, CUDA].include?( BOAST::get_lang ) end |
#to_str_c ⇒ Object
1374 1375 1376 1377 1378 |
# File 'lib/BOAST/Algorithm.rb', line 1374 def to_str_c s = "" s += "while(#{@condition}){" return s end |
#to_str_fortran ⇒ Object
1369 1370 1371 1372 1373 |
# File 'lib/BOAST/Algorithm.rb', line 1369 def to_str_fortran s = "" s += "do while( #{@condition} )" return s end |