Class: RedParse::UnlessOpNode

Inherits:
RawOpNode show all
Includes:
KeywordOpNode
Defined in:
lib/redparse/node.rb,
lib/redparse/node.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

Methods included from KeywordOpNode

#unparse

Methods inherited from RawOpNode

create, #image, #raw_unparse

Methods inherited from ValueNode

#lvalue

Methods inherited from Node

#+, #+@, #==, [], #[]=, #add_parent_links!, #begin_parsetree, create, #data, #deep_copy, #delete_extraneous_ivars!, #delete_linenums!, #depthwalk, #depthwalk_nodes, #error?, #evalable_inspect, #fixup_multiple_assignments!, #fixup_rescue_assignments!, #image, #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, #to_parsetree, #to_parsetree_and_warnings, #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

#identity_name

Constructor Details

#initialize(val1, op, val2 = nil) ⇒ UnlessOpNode

Returns a new instance of UnlessOpNode.



2826
2827
2828
2829
2830
2831
2832
2833
# File 'lib/redparse/node.rb', line 2826

def initialize(val1,op,val2=nil)
  op,val2=nil,op unless val2
  op=op.ident if op.respond_to? :ident
  @reverse=true
  @loop=false
  replace [val1,val2]
  condition.special_conditions! if condition.respond_to? :special_conditions!
end

Instance Method Details

#conditionObject



2824
# File 'lib/redparse/node.rb', line 2824

def condition; right end

#consequentObject



2825
# File 'lib/redparse/node.rb', line 2825

def consequent; left end

#elseObject



2837
# File 'lib/redparse/node.rb', line 2837

def else; consequent end

#elsifsObject



2838
# File 'lib/redparse/node.rb', line 2838

def elsifs; [] end

#ifObject



2835
# File 'lib/redparse/node.rb', line 2835

def if; condition end

#opObject



2839
# File 'lib/redparse/node.rb', line 2839

def op; "unless" end

#parsetree(o) ⇒ Object



2841
2842
2843
2844
2845
2846
2847
2848
2849
# File 'lib/redparse/node.rb', line 2841

def parsetree(o)
  cond=condition.rescue_parsetree(o)
  actions=[nil, consequent.parsetree(o)]
  if cond.first==:not
    actions.reverse!
    cond=cond.last
  end
  [:if, cond, *actions]
end

#thenObject



2836
# File 'lib/redparse/node.rb', line 2836

def then; nil end