Class: RedParse::Conditional

Inherits:
Object
  • Object
show all
Defined in:
lib/redparse/compile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(condition, action) ⇒ Conditional

Returns a new instance of Conditional.



653
654
655
656
# File 'lib/redparse/compile.rb', line 653

def initialize(condition,action)
  @condition,@action=condition,action
  @condition.restore :hash,:==
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



657
658
659
# File 'lib/redparse/compile.rb', line 657

def action
  @action
end

#conditionObject (readonly)

Returns the value of attribute condition.



657
658
659
# File 'lib/redparse/compile.rb', line 657

def condition
  @condition
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



662
663
664
# File 'lib/redparse/compile.rb', line 662

def == other
  Conditional===other and @condition==other.condition and @action==other.action
end

#hashObject



659
660
661
# File 'lib/redparse/compile.rb', line 659

def hash
  @condition.hash^@action.hash
end

#nameObject



667
# File 'lib/redparse/compile.rb', line 667

def name; @condition.inspect+"?"+@action.name end

#priorityObject



669
# File 'lib/redparse/compile.rb', line 669

def priority; @action.priority end