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.
1204 1205 1206 1207 |
# File 'lib/BOAST/Algorithm.rb', line 1204 def initialize(condition, &block) @condition = condition @block = block end |
Instance Attribute Details
#condition ⇒ Object (readonly)
Returns the value of attribute condition.
1203 1204 1205 |
# File 'lib/BOAST/Algorithm.rb', line 1203 def condition @condition end |
Class Method Details
.parens(*args, &block) ⇒ Object
1199 1200 1201 |
# File 'lib/BOAST/Algorithm.rb', line 1199 def self.parens(*args,&block) return self::new(*args,&block) end |
Instance Method Details
#close(final = true) ⇒ Object
1239 1240 1241 1242 |
# File 'lib/BOAST/Algorithm.rb', line 1239 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
1243 1244 1245 1246 1247 1248 1249 1250 |
# File 'lib/BOAST/Algorithm.rb', line 1243 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
1251 1252 1253 1254 1255 1256 1257 1258 |
# File 'lib/BOAST/Algorithm.rb', line 1251 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
1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 |
# File 'lib/BOAST/Algorithm.rb', line 1225 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
1208 1209 1210 |
# File 'lib/BOAST/Algorithm.rb', line 1208 def to_s self.to_str end |
#to_str ⇒ Object
1211 1212 1213 1214 |
# File 'lib/BOAST/Algorithm.rb', line 1211 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
1220 1221 1222 1223 1224 |
# File 'lib/BOAST/Algorithm.rb', line 1220 def to_str_c s = "" s += "while(#{@condition}){" return s end |
#to_str_fortran ⇒ Object
1215 1216 1217 1218 1219 |
# File 'lib/BOAST/Algorithm.rb', line 1215 def to_str_fortran s = "" s += "do while( #{@condition} )" return s end |