Class: ActionFactory::Assignments::Sequence

Inherits:
Object
  • Object
show all
Defined in:
lib/action_factory/assignments/sequence.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(block) ⇒ Sequence

Returns a new instance of Sequence.



8
9
10
11
# File 'lib/action_factory/assignments/sequence.rb', line 8

def initialize(block)
  @block = block
  @count = 0
end

Instance Attribute Details

#blockObject (readonly)

Returns the value of attribute block.



6
7
8
# File 'lib/action_factory/assignments/sequence.rb', line 6

def block
  @block
end

#countObject (readonly)

Returns the value of attribute count.



6
7
8
# File 'lib/action_factory/assignments/sequence.rb', line 6

def count
  @count
end

Instance Method Details

#==(other) ⇒ Object



17
18
19
# File 'lib/action_factory/assignments/sequence.rb', line 17

def ==(other)
  other.is_a?(self.class) && other.block == @block && other.count == @count
end

#compile(factory) ⇒ Object



13
14
15
# File 'lib/action_factory/assignments/sequence.rb', line 13

def compile(factory)
  factory.instance_exec(@count += 1, &@block)
end