Class: BOAST::Ternary
- Includes:
- Arithmetic
- Defined in:
- lib/BOAST/Operators.rb
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
-
#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
Methods included from Arithmetic
#!, #!=, #*, #+, #-, #-@, #/, #<, #<=, #==, #===, #>, #>=, #address, #dereference
Constructor Details
#initialize(x, y, z) ⇒ Ternary
Returns a new instance of Ternary.
413 414 415 416 417 |
# File 'lib/BOAST/Operators.rb', line 413 def initialize(x,y,z) @operand1 = x @operand2 = y @operand3 = z end |
Instance Attribute Details
#operand1 ⇒ Object (readonly)
Returns the value of attribute operand1.
409 410 411 |
# File 'lib/BOAST/Operators.rb', line 409 def operand1 @operand1 end |
#operand2 ⇒ Object (readonly)
Returns the value of attribute operand2.
410 411 412 |
# File 'lib/BOAST/Operators.rb', line 410 def operand2 @operand2 end |
#operand3 ⇒ Object (readonly)
Returns the value of attribute operand3.
411 412 413 |
# File 'lib/BOAST/Operators.rb', line 411 def operand3 @operand3 end |
Class Method Details
.parens(*args, &block) ⇒ Object
405 406 407 |
# File 'lib/BOAST/Operators.rb', line 405 def self.parens(*args,&block) return self::new(*args,&block) end |
Instance Method Details
#print(final = true) ⇒ Object
431 432 433 434 435 436 437 438 |
# File 'lib/BOAST/Operators.rb', line 431 def print(final=true) s="" s += " "*BOAST::get_indent_level if final s += self.to_str s += ";" if final and [BOAST::C, BOAST::CL, BOAST::CUDA].include?( BOAST::get_lang ) BOAST::get_output.puts s if final return s end |
#to_s ⇒ Object
419 420 421 |
# File 'lib/BOAST/Operators.rb', line 419 def to_s self.to_str end |
#to_str ⇒ Object
423 424 425 426 |
# File 'lib/BOAST/Operators.rb', line 423 def to_str raise "Ternary operator unsupported in FORTRAN!" if BOAST::get_lang == BOAST::FORTRAN return self.to_str_c if [BOAST::C, BOAST::CL, BOAST::CUDA].include?( BOAST::get_lang ) end |
#to_str_c ⇒ Object
427 428 429 430 |
# File 'lib/BOAST/Operators.rb', line 427 def to_str_c s = "" s += "(#{@operand1} ? #{@operand2} : #{@operand3})" end |