Class: Phase

Inherits:
Object
  • Object
show all
Defined in:
lib/rf_app_serializer/phase.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#indexObject

Returns the value of attribute index.



2
3
4
# File 'lib/rf_app_serializer/phase.rb', line 2

def index
  @index
end

#nameObject

Returns the value of attribute name.



2
3
4
# File 'lib/rf_app_serializer/phase.rb', line 2

def name
  @name
end

#stepsObject

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_stepObject



21
22
23
# File 'lib/rf_app_serializer/phase.rb', line 21

def most_recent_step
  steps.find { |step| step[:started_at] }[:name]
end