Class: Rapid::Model::Item

Inherits:
Compo::Branches::Leaf
  • Object
show all
Includes:
Common::Types::Validators, ModelObject
Defined in:
lib/ury_rapid/model/item.rb

Overview

An item in the playout system.

Instance Attribute Summary collapse

Attributes included from ModelObject

#handler_target

Instance Method Summary collapse

Methods included from ModelObject

#default_handler_target, #default_id, #get, #insert, #post_to_parent, #register_handler

Methods included from Updatable

#deregister_from_updates, #notify_delete, #notify_update, #register_for_updates, #register_update_channel

Methods included from Common::Types::Validators

invalid, validate_marker, validate_symbol, validate_volume

Constructor Details

#initialize(type, name, origin, duration) ⇒ Item

Creates a new Item

Examples:

Create a library track item.

Item.new(:library, 'Islands In The Stream'

31
32
33
34
35
36
37
38
# File 'lib/ury_rapid/model/item.rb', line 31

def initialize(type, name, origin, duration)
  super()

  @type = type
  @name = name
  @origin = origin
  @duration = duration
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name


14
15
16
# File 'lib/ury_rapid/model/item.rb', line 14

def name
  @name
end

#typeObject (readonly)

Access the track type.


17
18
19
# File 'lib/ury_rapid/model/item.rb', line 17

def type
  @type
end

Instance Method Details

#flatHash

Converts the Item to a flat representation

This conversion is not reversible and may lose some information.


45
46
47
# File 'lib/ury_rapid/model/item.rb', line 45

def flat
  { name: @name, type: @type, origin: @origin, duration: @duration }
end

#killvoid

This method returns an undefined value.

Kills this Item


62
63
64
65
66
67
# File 'lib/ury_rapid/model/item.rb', line 62

def kill  # Must notify before changing parent, as the notification requires
  # a valid full URL.

  notify_delete
  move_to(nil, nil)
end

#replace(new_item) ⇒ Object

PUTs a new item representation into this Item from the service end

This just asks the parent to POST the new item over this one, for the sake of convenience.


55
56
57
# File 'lib/ury_rapid/model/item.rb', line 55

def replace(new_item)
  parent.insert(id, new_item)
end