Class: Phase
- Inherits:
-
Object
- Object
- Phase
- Defined in:
- lib/rf_app_serializer/phase.rb
Instance Attribute Summary collapse
-
#index ⇒ Object
Returns the value of attribute index.
-
#name ⇒ Object
Returns the value of attribute name.
-
#steps ⇒ Object
Returns the value of attribute steps.
Instance Method Summary collapse
-
#initialize(name:, steps:, index:) ⇒ Phase
constructor
A new instance of Phase.
- #is_complete? ⇒ Boolean
- #is_current? ⇒ Boolean
- #is_started? ⇒ Boolean
- #most_recent_step ⇒ Object
Constructor Details
#initialize(name:, steps:, index:) ⇒ Phase
3 4 5 6 7 |
# File 'lib/rf_app_serializer/phase.rb', line 3 def initialize(name:, steps:, index:) @name = name @steps = steps @index = index end |
Instance Attribute Details
#index ⇒ Object
Returns the value of attribute index.
2 3 4 |
# File 'lib/rf_app_serializer/phase.rb', line 2 def index @index end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/rf_app_serializer/phase.rb', line 2 def name @name end |
#steps ⇒ Object
Returns the value of attribute steps.
2 3 4 |
# File 'lib/rf_app_serializer/phase.rb', line 2 def steps @steps end |
Instance Method Details
#is_complete? ⇒ Boolean
9 10 11 |
# File 'lib/rf_app_serializer/phase.rb', line 9 def is_complete? steps.all? { |step| step[:completed_at] } end |
#is_current? ⇒ Boolean
17 18 19 |
# File 'lib/rf_app_serializer/phase.rb', line 17 def is_current? is_started? && !is_complete? end |
#is_started? ⇒ Boolean
13 14 15 |
# File 'lib/rf_app_serializer/phase.rb', line 13 def is_started? steps.any? { |step| step[:started_at] } end |
#most_recent_step ⇒ Object
21 22 23 |
# File 'lib/rf_app_serializer/phase.rb', line 21 def most_recent_step steps.find { |step| step[:started_at] }[:name] end |