Class: SelfControl::FlowBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/self-control/flow_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(state, &flow) ⇒ FlowBuilder

Returns a new instance of FlowBuilder.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/self-control/flow_builder.rb', line 5

def initialize(state, &flow)
  @state = state
  @steps ||= []
  @actors ||= []
  @actions ||= []
  
  instance_eval(&flow)
  
  @actors = @actors.flatten.compact.uniq
  @actions = @actions.flatten.compact.uniq
end

Instance Attribute Details

#actionsObject

Returns the value of attribute actions.



3
4
5
# File 'lib/self-control/flow_builder.rb', line 3

def actions
  @actions
end

#actorsObject

Returns the value of attribute actors.



3
4
5
# File 'lib/self-control/flow_builder.rb', line 3

def actors
  @actors
end

#stateObject

Returns the value of attribute state.



3
4
5
# File 'lib/self-control/flow_builder.rb', line 3

def state
  @state
end

#stepsObject

Returns the value of attribute steps.



3
4
5
# File 'lib/self-control/flow_builder.rb', line 3

def steps
  @steps
end

Instance Method Details

#doable_stepsObject



21
22
23
# File 'lib/self-control/flow_builder.rb', line 21

def doable_steps
  @steps.select(&:doable?)
end

#totalObject



17
18
19
# File 'lib/self-control/flow_builder.rb', line 17

def total
  @steps.size
end

#total_doableObject



25
26
27
# File 'lib/self-control/flow_builder.rb', line 25

def total_doable
  doable_steps.size
end