Class: RedParse::TernaryNode
- Defined in:
- lib/redparse/node.rb,
lib/redparse/ripper.rb,
lib/redparse/ReduceWithsFor_RedParse_1_9.rb,
lib/redparse/ReduceWithsFor_RedParse_1_8.rb
Constant Summary
Constants included from FlattenedIvars
FlattenedIvars::EXCLUDED_IVARS
Instance Attribute Summary
Attributes inherited from Node
#endline, #errors, #offset, #parent, #startline
Attributes included from Stackable::Meta
#boolean_identity_params, #identity_params
Instance Method Summary collapse
- #elsifs ⇒ Object
- #image ⇒ Object
-
#initialize(if_, qm, then_, colon, else_) ⇒ TernaryNode
constructor
A new instance of TernaryNode.
- #parsetree(o) ⇒ Object
- #reducer_ident ⇒ Object
- #rip(p) ⇒ Object
- #unparse(o = default_unparse_options) ⇒ Object
Methods inherited from ValueNode
Methods inherited from Node
#+, #+@, #==, [], #[]=, #add_parent_links!, #args_rip, #begin_parsetree, #classic_inspect, create, #data, #deep_copy, #delete_extraneous_ivars!, #delete_linenums!, #depthwalk, #depthwalk_nodes, #error?, #evalable_inspect, #fixup_multiple_assignments!, #fixup_rescue_assignments!, #force_stmt_list_rip, #initialize_ivars, inline_symbols, #inspect, #lhs_unparse, #linerange, #lvalue, #lvars_defined_in, #merge_replacement_session, namelist, #negate, #original_brackets_assign, param_names, #parsetrees, #pretty_print, #prohibit_fixup, #replace_ivars_and_self, #replace_value, #rescue_parsetree, #rfind, #rfind_all, #rgrep, #rip_and_rescues, #rip_explode!, #short_inspect, #stmts_rip, #to_parsetree, #to_parsetree_and_warnings, #to_ruby, #to_s, #unary, #walk, #xform_tree!
Methods included from Stackable::Meta
#build_exemplars, #enumerate_exemplars, #identity_param
Methods included from FlattenedIvars
#flattened_ivars, #flattened_ivars_equal?
Methods included from Stackable
Constructor Details
#initialize(if_, qm, then_, colon, else_) ⇒ TernaryNode
Returns a new instance of TernaryNode.
4739 4740 4741 4742 4743 |
# File 'lib/redparse/node.rb', line 4739 def initialize(if_,qm,then_,colon,else_) super(if_,then_,else_) condition.special_conditions! if condition.respond_to? :special_conditions! @offset=self.first.offset end |
Instance Method Details
#elsifs ⇒ Object
4751 |
# File 'lib/redparse/node.rb', line 4751 def elsifs; [] end |
#image ⇒ Object
4745 |
# File 'lib/redparse/node.rb', line 4745 def image; "(?:)" end |
#parsetree(o) ⇒ Object
4753 4754 4755 4756 4757 |
# File 'lib/redparse/node.rb', line 4753 def parsetree(o) cond=condition.rescue_parsetree(o) cond[0]=:fcall if cond[0]==:vcall and cond[1].to_s[/[?!]$/] [:if, cond, consequent.begin_parsetree(o), otherwise.begin_parsetree(o)] end |
#reducer_ident ⇒ Object
17335 17336 17337 |
# File 'lib/redparse/ReduceWithsFor_RedParse_1_9.rb', line 17335 def reducer_ident :TernaryNode end |
#rip(p) ⇒ Object
366 367 368 |
# File 'lib/redparse/ripper.rb', line 366 def rip p p.on_ifop condition.rip(p), consequent.rip(p), otherwise.rip(p) end |
#unparse(o = default_unparse_options) ⇒ Object
4747 4748 4749 |
# File 'lib/redparse/node.rb', line 4747 def unparse o= "#{condition.unparse o} ? #{consequent.unparse o} : #{otherwise.unparse o}" end |