Class: Smash::CloudPowers::Workflow

Inherits:
Object
  • Object
show all
Defined in:
lib/cloud_powers/workflow.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(statez = nil) ⇒ Workflow

Returns a new instance of Workflow.



6
7
8
9
10
11
12
13
# File 'lib/cloud_powers/workflow.rb', line 6

def initialize(statez = nil)
  # TODO: figure out wtf here with the i-vars changing each other
  @all_states = statez || [:backlog, :wip, :done]
  @states = statez || [:backlog, :wip, :done]
  @first = (statez || [:backlog, :wip, :done]).first
  @last = (statez || [:backlog, :wip, :done]).last
  @previous = [(statez || [:backlog, :wip, :done]).first]
end

Instance Attribute Details

#all_states ⇒ Object

Returns the value of attribute all_states.



4
5
6
# File 'lib/cloud_powers/workflow.rb', line 4

def all_states
  @all_states
end

#first ⇒ Object

Returns the value of attribute first.



4
5
6
# File 'lib/cloud_powers/workflow.rb', line 4

def first
  @first
end

#last ⇒ Object

Returns the value of attribute last.



4
5
6
# File 'lib/cloud_powers/workflow.rb', line 4

def last
  @last
end

#previous ⇒ Object

Returns the value of attribute previous.



4
5
6
# File 'lib/cloud_powers/workflow.rb', line 4

def previous
  @previous
end

#states ⇒ Object

Returns the value of attribute states.



4
5
6
# File 'lib/cloud_powers/workflow.rb', line 4

def states
  @states
end

Instance Method Details

#current ⇒ Object



15
16
17
# File 'lib/cloud_powers/workflow.rb', line 15

def current
  @states.first
end

#finished? ⇒ Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/cloud_powers/workflow.rb', line 19

def finished?
  @states.first == @states.last
end

#next ⇒ Object



23
24
25
# File 'lib/cloud_powers/workflow.rb', line 23

def next
  finished ? @states.first : @states[1]
end

#next! ⇒ Object



27
28
29
30
31
# File 'lib/cloud_powers/workflow.rb', line 27

def next!
  return if finished?
  @previous << @states.shift
  @states.first
end