Class: Loxxy::BackEnd::UnaryOperator
- Inherits:
-
Object
- Object
- Loxxy::BackEnd::UnaryOperator
- Defined in:
- lib/loxxy/back_end/unary_operator.rb
Overview
A Lox unary operator
Instance Attribute Summary collapse
-
#name ⇒ String
readonly
Text representation of the operator.
- #signatures ⇒ Array<Class> readonly
Instance Method Summary collapse
-
#initialize(aName, theSignatures) ⇒ UnaryOperator
constructor
A new instance of UnaryOperator.
- #validate_operand(operand1) ⇒ Object
Constructor Details
#initialize(aName, theSignatures) ⇒ UnaryOperator
Returns a new instance of UnaryOperator.
17 18 19 20 |
# File 'lib/loxxy/back_end/unary_operator.rb', line 17 def initialize(aName, theSignatures) @name = aName @signatures = theSignatures end |
Instance Attribute Details
#name ⇒ String (readonly)
Returns text representation of the operator.
10 11 12 |
# File 'lib/loxxy/back_end/unary_operator.rb', line 10 def name @name end |
#signatures ⇒ Array<Class> (readonly)
13 14 15 |
# File 'lib/loxxy/back_end/unary_operator.rb', line 13 def signatures @signatures end |
Instance Method Details
#validate_operand(operand1) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/loxxy/back_end/unary_operator.rb', line 22 def validate_operand(operand1) compliant = signatures.find { |some_type| operand1.kind_of?(some_type) } unless compliant err = Loxxy::RuntimeError # if signatures.size == 1 raise err, "Operand must be a #{datatype_name(signatures[0])}." # end end end |