Class: BOAST::Ternary
- Inherits:
-
Object
- Object
- BOAST::Ternary
- Extended by:
- Functor
- Includes:
- Arithmetic, Inspectable, PrivateStateAccessor
- 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.
Instance Method Summary collapse
-
#initialize(x, y, z) ⇒ Ternary
constructor
A new instance of Ternary.
- #pr ⇒ Object
- #to_s ⇒ Object
- #to_s_c ⇒ Object
Methods included from Functor
Methods included from PrivateStateAccessor
private_boolean_state_accessor, private_state_accessor
Methods included from Inspectable
Methods included from Arithmetic
#!, #!=, #*, #+, #-, #-@, #/, #<, #<=, #==, #===, #>, #>=, #address, #and, #components, #dereference, #or
Constructor Details
#initialize(x, y, z) ⇒ Ternary
Returns a new instance of Ternary.
461 462 463 464 465 |
# File 'lib/BOAST/Operators.rb', line 461 def initialize(x,y,z) @operand1 = x @operand2 = y @operand3 = z end |
Instance Attribute Details
#operand1 ⇒ Object (readonly)
Returns the value of attribute operand1.
457 458 459 |
# File 'lib/BOAST/Operators.rb', line 457 def operand1 @operand1 end |
#operand2 ⇒ Object (readonly)
Returns the value of attribute operand2.
458 459 460 |
# File 'lib/BOAST/Operators.rb', line 458 def operand2 @operand2 end |
#operand3 ⇒ Object (readonly)
Returns the value of attribute operand3.
459 460 461 |
# File 'lib/BOAST/Operators.rb', line 459 def operand3 @operand3 end |
Instance Method Details
#pr ⇒ Object
477 478 479 480 481 482 483 484 |
# File 'lib/BOAST/Operators.rb', line 477 def pr s="" s += indent s += to_s s += ";" if [C, CL, CUDA].include?( lang ) output.puts s return self end |
#to_s ⇒ Object
467 468 469 470 |
# File 'lib/BOAST/Operators.rb', line 467 def to_s raise "Ternary operator unsupported in FORTRAN!" if lang == FORTRAN return to_s_c if [C, CL, CUDA].include?( lang ) end |
#to_s_c ⇒ Object
472 473 474 475 |
# File 'lib/BOAST/Operators.rb', line 472 def to_s_c s = "" s += "(#{@operand1} ? #{@operand2} : #{@operand3})" end |