Class: NoSE::Plans::UpdatePlanStep

Inherits:
PlanStep show all
Defined in:
lib/nose/plans/update.rb

Overview

A superclass for steps which modify indexes

Direct Known Subclasses

DeletePlanStep, InsertPlanStep

Instance Attribute Summary collapse

Attributes inherited from PlanStep

#children, #cost, #fields, #parent

Instance Method Summary collapse

Methods inherited from PlanStep

#add_fields_from_index, #calculate_cost, inherited, #parent_index, #parent_steps

Methods included from Supertype

included

Constructor Details

#initialize(index, type, state = nil) ⇒ UpdatePlanStep

Returns a new instance of UpdatePlanStep.



10
11
12
13
14
15
16
17
18
# File 'lib/nose/plans/update.rb', line 10

def initialize(index, type, state = nil)
  super()
  @index = index
  @type = type

  return if state.nil?
  @state = state.dup
  @state.freeze
end

Instance Attribute Details

#indexObject (readonly)

Returns the value of attribute index.



7
8
9
# File 'lib/nose/plans/update.rb', line 7

def index
  @index
end

#stateObject

Returns the value of attribute state.



8
9
10
# File 'lib/nose/plans/update.rb', line 8

def state
  @state
end

Instance Method Details

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

Two insert steps are equal if they use the same index



27
28
29
30
# File 'lib/nose/plans/update.rb', line 27

def ==(other)
  other.instance_of?(self.class) && @index == other.index && \
    @type == other.instance_variable_get(:@type)
end

#hashObject



33
34
35
# File 'lib/nose/plans/update.rb', line 33

def hash
  [@index, @type].hash
end

#to_colorObject

:nocov:



21
22
23
# File 'lib/nose/plans/update.rb', line 21

def to_color
  "#{super} #{@index.to_color} * #{@state.cardinality}"
end