Class: SelfControl::FlowBuilder
- Inherits:
-
Object
- Object
- SelfControl::FlowBuilder
- Defined in:
- lib/self-control/flow_builder.rb
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#actors ⇒ Object
Returns the value of attribute actors.
-
#state ⇒ Object
Returns the value of attribute state.
-
#steps ⇒ Object
Returns the value of attribute steps.
Instance Method Summary collapse
- #doable_steps ⇒ Object
-
#initialize(state, &flow) ⇒ FlowBuilder
constructor
A new instance of FlowBuilder.
- #total ⇒ Object
- #total_doable ⇒ Object
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
#actions ⇒ Object
Returns the value of attribute actions.
3 4 5 |
# File 'lib/self-control/flow_builder.rb', line 3 def actions @actions end |
#actors ⇒ Object
Returns the value of attribute actors.
3 4 5 |
# File 'lib/self-control/flow_builder.rb', line 3 def actors @actors end |
#state ⇒ Object
Returns the value of attribute state.
3 4 5 |
# File 'lib/self-control/flow_builder.rb', line 3 def state @state end |
#steps ⇒ Object
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_steps ⇒ Object
21 22 23 |
# File 'lib/self-control/flow_builder.rb', line 21 def doable_steps @steps.select(&:doable?) end |
#total ⇒ Object
17 18 19 |
# File 'lib/self-control/flow_builder.rb', line 17 def total @steps.size end |
#total_doable ⇒ Object
25 26 27 |
# File 'lib/self-control/flow_builder.rb', line 25 def total_doable doable_steps.size end |