Class: RfAppSerializer

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(phases) ⇒ RfAppSerializer

Returns a new instance of RfAppSerializer.



6
7
8
# File 'lib/rf_app_serializer.rb', line 6

def initialize(phases)
  @phases = phases.each_with_index.map { |phase, index| Phase.new(name: phase[:name], steps: phase[:steps], index: index) }
end

Instance Attribute Details

#phasesObject

Returns the value of attribute phases.



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

def phases
  @phases
end

Instance Method Details

#active_phaseObject



16
17
18
19
20
21
# File 'lib/rf_app_serializer.rb', line 16

def active_phase
  {
    name: find_active_phase.name,
    index: find_active_phase.index
  }
end

#active_stepObject



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

def active_step
  find_active_phase.most_recent_step
end

#find_active_phaseObject



10
11
12
13
14
# File 'lib/rf_app_serializer.rb', line 10

def find_active_phase
  phases.find do |phase|
    phase.is_started?
  end
end