Class: BOAST::Ternary
Instance Attribute Summary collapse
-
#operand1 ⇒ Object
readonly
Returns the value of attribute operand1.
-
#operand2 ⇒ Object
readonly
Returns the value of attribute operand2.
-
#operand3 ⇒ Object
readonly
Returns the value of attribute operand3.
Class Method Summary collapse
Instance Method Summary collapse
- #*(x) ⇒ Object
- #+(x) ⇒ Object
- #-(x) ⇒ Object
- #-@ ⇒ Object
- #<(x) ⇒ Object
- #==(x) ⇒ Object
- #>=(x) ⇒ Object
- #[](*args) ⇒ Object
-
#initialize(x, y, z) ⇒ Ternary
constructor
A new instance of Ternary.
- #print(final = true) ⇒ Object
- #to_s ⇒ Object
- #to_str ⇒ Object
- #to_str_c ⇒ Object
Constructor Details
#initialize(x, y, z) ⇒ Ternary
Returns a new instance of Ternary.
1201 1202 1203 1204 1205 |
# File 'lib/BOAST/Algorithm.rb', line 1201 def initialize(x,y,z) @operand1 = x @operand2 = y @operand3 = z end |
Instance Attribute Details
#operand1 ⇒ Object (readonly)
Returns the value of attribute operand1.
1197 1198 1199 |
# File 'lib/BOAST/Algorithm.rb', line 1197 def operand1 @operand1 end |
#operand2 ⇒ Object (readonly)
Returns the value of attribute operand2.
1198 1199 1200 |
# File 'lib/BOAST/Algorithm.rb', line 1198 def operand2 @operand2 end |
#operand3 ⇒ Object (readonly)
Returns the value of attribute operand3.
1199 1200 1201 |
# File 'lib/BOAST/Algorithm.rb', line 1199 def operand3 @operand3 end |
Class Method Details
.parens(*args, &block) ⇒ Object
1193 1194 1195 |
# File 'lib/BOAST/Algorithm.rb', line 1193 def self.parens(*args,&block) return self::new(*args,&block) end |
Instance Method Details
#*(x) ⇒ Object
1223 1224 1225 |
# File 'lib/BOAST/Algorithm.rb', line 1223 def *(x) return Expression::new("*",self,x) end |
#+(x) ⇒ Object
1211 1212 1213 |
# File 'lib/BOAST/Algorithm.rb', line 1211 def +(x) return Expression::new("+",self,x) end |
#-(x) ⇒ Object
1227 1228 1229 |
# File 'lib/BOAST/Algorithm.rb', line 1227 def -(x) return Expression::new("-",self,x) end |
#-@ ⇒ Object
1231 1232 1233 |
# File 'lib/BOAST/Algorithm.rb', line 1231 def -@ return Expression::new("-",nil,self) end |
#<(x) ⇒ Object
1215 1216 1217 |
# File 'lib/BOAST/Algorithm.rb', line 1215 def <(x) return Expression::new("<",self,x) end |
#==(x) ⇒ Object
1207 1208 1209 |
# File 'lib/BOAST/Algorithm.rb', line 1207 def ==(x) return Expression::new("==",self,x) end |
#>=(x) ⇒ Object
1219 1220 1221 |
# File 'lib/BOAST/Algorithm.rb', line 1219 def >=(x) return Expression::new(">=",self,x) end |
#[](*args) ⇒ Object
1235 1236 1237 |
# File 'lib/BOAST/Algorithm.rb', line 1235 def [](*args) return Index::new(self,args) end |
#print(final = true) ⇒ Object
1251 1252 1253 1254 1255 1256 1257 1258 |
# File 'lib/BOAST/Algorithm.rb', line 1251 def print(final=true) s="" s += " "*BOAST::get_indent_level if final s += self.to_str s += ";" if final and [C, CL, CUDA].include?( BOAST::get_lang ) BOAST::get_output.puts s if final return s end |
#to_s ⇒ Object
1239 1240 1241 |
# File 'lib/BOAST/Algorithm.rb', line 1239 def to_s self.to_str end |
#to_str ⇒ Object
1243 1244 1245 1246 |
# File 'lib/BOAST/Algorithm.rb', line 1243 def to_str raise "Ternary operator unsupported in FORTRAN!" if BOAST::get_lang == FORTRAN return self.to_str_c if [C, CL, CUDA].include?( BOAST::get_lang ) end |
#to_str_c ⇒ Object
1247 1248 1249 1250 |
# File 'lib/BOAST/Algorithm.rb', line 1247 def to_str_c s = "" s += "(#{@operand1} ? #{@operand2} : #{@operand3})" end |