Class: Henitai::Operators::UnaryOperator
- Inherits:
-
Henitai::Operator
- Object
- Henitai::Operator
- Henitai::Operators::UnaryOperator
- Defined in:
- lib/henitai/operators/unary_operator.rb
Overview
Removes unary prefix operators by replacing the send node with its receiver.
Covers :-@ (unary minus) and :~ (bitwise NOT). Unary negation (!) is intentionally excluded — BooleanLiteral owns that.
Constant Summary collapse
- NODE_TYPES =
%i[send].freeze
- UNARY_METHODS =
%i[-@ ~].freeze
Constants inherited from Henitai::Operator
Henitai::Operator::FULL_SET, Henitai::Operator::LIGHT_SET
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Henitai::Operator
Class Method Details
.node_types ⇒ Object
15 16 17 |
# File 'lib/henitai/operators/unary_operator.rb', line 15 def self.node_types NODE_TYPES end |
Instance Method Details
#mutate(node, subject:) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/henitai/operators/unary_operator.rb', line 19 def mutate(node, subject:) receiver, method_name, *arguments = node.children return [] unless UNARY_METHODS.include?(method_name) return [] unless arguments.empty? return [] unless receiver [ build_mutant( subject:, original_node: node, mutated_node: receiver, description: "removed unary #{method_name.to_s.delete('@')}" ) ] end |