Class: Arbetsformedlingen::Schedule

Inherits:
Model
  • Object
show all
Defined in:
lib/arbetsformedlingen/models/schedule.rb

Constant Summary collapse

DURATION_MAP =
{
  regular: -1,
  from_0_days_to_10_days: 8,
  from_11_days_to_3_months: 7,
  from_june_to_august: 4, # summer months (June to August)
  from_3_months_to_6_months: 3,
  from_6_months_to_longer: 2,
}.freeze

Instance Attribute Summary

Attributes inherited from Model

#schema

Instance Method Summary collapse

Methods inherited from Model

#errors, from_schema, #to_h, #valid?

Constructor Details

#initialize(hash) ⇒ Schedule

Returns a new instance of Schedule.



30
31
32
33
34
35
36
# File 'lib/arbetsformedlingen/models/schedule.rb', line 30

def initialize(hash)
  data = hash.dup
  duration_code = duration_code(data[:start_date], data[:end_date])
  data[:position_duration_code] = duration_code
  data[:full_time] = duration_code == -1
  super(ScheduleSchema.call(data))
end