Class: Y2R::AST::Ruby::UnaryOperator
- Inherits:
-
Node
- Object
- OpenStruct
- Node
- Y2R::AST::Ruby::UnaryOperator
show all
- Defined in:
- lib/y2r/ast/ruby.rb
Constant Summary
collapse
- OPS_TO_PRIORITIES =
{
"!" => Priority::UNARY,
"~" => Priority::UNARY,
"+" => Priority::UNARY,
"-" => Priority::UNARY_MINUS
}
Constants inherited
from Node
Node::INDENT_STEP
Instance Method Summary
collapse
Methods inherited from Node
#ensure_separated, #has_comment?, #hates_to_stand_alone?, #single_line_width, #starts_with_comment?, #to_ruby
Instance Method Details
937
938
939
|
# File 'lib/y2r/ast/ruby.rb', line 937
def
|| expression.
end
|
#pass_trailer? ⇒ Boolean
941
942
943
|
# File 'lib/y2r/ast/ruby.rb', line 941
def pass_trailer?
true
end
|
#priority ⇒ Object
933
934
935
|
# File 'lib/y2r/ast/ruby.rb', line 933
def priority
OPS_TO_PRIORITIES[op]
end
|
#single_line_width_base(context) ⇒ Object
927
928
929
930
931
|
# File 'lib/y2r/ast/ruby.rb', line 927
def single_line_width_base(context)
inner_context = context.with_priority(priority)
op.size + expression.single_line_width(inner_context)
end
|
#to_ruby_base(context) ⇒ Object
921
922
923
924
925
|
# File 'lib/y2r/ast/ruby.rb', line 921
def to_ruby_base(context)
expressions_context = context.shifted(op.size).with_priority(priority)
"#{op}#{expression.to_ruby(expressions_context)}"
end
|