Initial commit

This commit is contained in:
Senad Uka
2022-03-23 05:44:42 +01:00
parent 1405281a5c
commit eea10dd03b
113 changed files with 3617 additions and 81 deletions

View File

@@ -0,0 +1,37 @@
# frozen_string_literal: true
module SchedulePipeline
module Models
class Schedule
attr_reader :name, :vendor, :player, :start_time, :items
def initialize(name, vendor, player, start_time, items)
@name = name
@vendor = vendor
@player = player
@start_time = start_time
@items = items
end
def to_hash
{
name: name,
vendor: vendor,
player: player,
start_time: start_time,
items: items.collect(&:to_hash)
}.with_indifferent_access
end
def self.from_hash(input)
self.new(
input[:name],
input[:vendor],
input[:player],
input[:start_time],
input[:items].collect { |i| ScheduleItem.from_hash(i) }
)
end
end
end
end

View File

@@ -0,0 +1,26 @@
# frozen_string_literal: true
module SchedulePipeline
module Models
class ScheduleFetchMsg
attr_reader :vendor, :params
def initialize(vendor, params)
@vendor = vendor
@params = params
end
def send(queue)
queue.push(serialized_msg)
end
private
def serialized_msg
{
vendor: @vendor,
params: @params
}
end
end
end
end

View File

@@ -0,0 +1,31 @@
# frozen_string_literal: true
module SchedulePipeline
module Models
class ScheduleItem
attr_reader :duration, :content_key, :pop_data
def initialize(duration, content_key, pop_data)
@duration = duration
@content_key = content_key
@pop_data = pop_data
end
def to_hash
{
duration: @duration,
content_key: @content_key,
pop_data: @pop_data
}.with_indifferent_access
end
def self.from_hash(input)
self.new(
input[:duration],
input[:content_key],
input[:pop_data]
)
end
end
end
end

View File

@@ -0,0 +1,35 @@
# frozen_string_literal: true
module SchedulePipeline
module Models
class ScheduleProcessMsg
attr_reader :vendor, :player, :vendor_schedule
def initialize(vendor, player, schedule)
@vendor = vendor
@player = player
@vendor_schedule = schedule.with_indifferent_access
end
def push(queue)
queue.push(to_hash)
end
def to_hash
{
vendor: @vendor,
player: @player,
vendor_schedule: @vendor_schedule
}
end
def self.from_hash(input)
self.new(
input[:vendor],
input[:player],
input[:vendor_schedule],
)
end
end
end
end