Class: Rapid::Examples::FakePlayoutService

Inherits:
Services::Service show all
Defined in:
lib/ury_rapid/examples/fake_playout_service.rb

Overview

A fake playout service

The FakePlayoutService builds up a model that looks like a playout service, but cannot be controlled.

Its configuration DSL exposes the following methods:

  • 'channels': Takes a list of valid channel IDs.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment) ⇒ FakePlayoutService

Initialises the service

Examples:

Create a new HelloWorldService

service = HelloWorldService.new(view)

Parameters:


22
23
24
25
26
27
28
29
# File 'lib/ury_rapid/examples/fake_playout_service.rb', line 22

def initialize(environment)
  # We need to initialise Rapid::Services::Service with the
  # environment
  super(environment)

  # The default channel set, overridden by #channels.
  @channels = {}
end

Instance Attribute Details

#channels=(value) ⇒ void (writeonly) Also known as: channels

This method returns an undefined value.

Sets the list of channel IDs.

Examples:

Set the channel IDs to ['0', '1', '2', '3']

# In config.rb
channels ['0', '1', '2', '3']

Parameters:

  • ids (Array)

    The array of channel IDs to use.


67
68
69
# File 'lib/ury_rapid/examples/fake_playout_service.rb', line 67

def channels=(value)
  @channels = value
end

Instance Method Details

#runvoid

This method returns an undefined value.

Runs the service on the EventMachine loop

Since we have no EventMachine-bound connections, timers, or I/O tasks, this is empty.

Examples:

Run the HelloWorldService.

service.run

41
42
43
44
45
46
47
48
49
50
# File 'lib/ury_rapid/examples/fake_playout_service.rb', line 41

def run
  # #insert_components is an instance-exec, so this won't be available
  # as an instance variable.
  c = @channels
  pm = Rapid::Model::Structures.playout_model(c)

  environment.insert_components('/') do
    instance_eval(&pm)
  end
end