Class: Tangerine::Video

Inherits:
Base
  • Object
show all
Defined in:
lib/tangerine/backlot/video.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all, find, finder, prepare_items

Constructor Details

#initialize(options = {}) ⇒ Video

end



28
29
30
31
32
33
34
35
36
# File 'lib/tangerine/backlot/video.rb', line 28

def initialize(options={})
  @options = options
  
  add_labels

  options.delete('metadata')
  options.delete('labels')
  super(options)
end

Instance Attribute Details

#contentObject

Returns the value of attribute content.



3
4
5
# File 'lib/tangerine/backlot/video.rb', line 3

def content
  @content
end

#descriptionObject

Returns the value of attribute description.



3
4
5
# File 'lib/tangerine/backlot/video.rb', line 3

def description
  @description
end

#embed_codeObject

Returns the value of attribute embed_code.



3
4
5
# File 'lib/tangerine/backlot/video.rb', line 3

def embed_code
  @embed_code
end

#flight_start_timeObject

Returns the value of attribute flight_start_time.



3
4
5
# File 'lib/tangerine/backlot/video.rb', line 3

def flight_start_time
  @flight_start_time
end

#heightObject

Returns the value of attribute height.



3
4
5
# File 'lib/tangerine/backlot/video.rb', line 3

def height
  @height
end

#labelsObject

Returns the value of attribute labels.



3
4
5
# File 'lib/tangerine/backlot/video.rb', line 3

def labels
  @labels
end

#lengthObject

Returns the value of attribute length.



3
4
5
# File 'lib/tangerine/backlot/video.rb', line 3

def length
  @length
end

#metadataObject

Returns the value of attribute metadata.



3
4
5
# File 'lib/tangerine/backlot/video.rb', line 3

def 
  @metadata
end

#sizeObject

Returns the value of attribute size.



3
4
5
# File 'lib/tangerine/backlot/video.rb', line 3

def size
  @size
end

#statObject

Returns the value of attribute stat.



3
4
5
# File 'lib/tangerine/backlot/video.rb', line 3

def stat
  @stat
end

#statusObject

Returns the value of attribute status.



3
4
5
# File 'lib/tangerine/backlot/video.rb', line 3

def status
  @status
end

#thumbnailObject

Returns the value of attribute thumbnail.



3
4
5
# File 'lib/tangerine/backlot/video.rb', line 3

def thumbnail
  @thumbnail
end

#titleObject

Returns the value of attribute title.



3
4
5
# File 'lib/tangerine/backlot/video.rb', line 3

def title
  @title
end

#updated_atObject

Returns the value of attribute updated_at.



3
4
5
# File 'lib/tangerine/backlot/video.rb', line 3

def updated_at
  @updated_at
end

#uploaded_atObject

Returns the value of attribute uploaded_at.



3
4
5
# File 'lib/tangerine/backlot/video.rb', line 3

def uploaded_at
  @uploaded_at
end

#widthObject

Returns the value of attribute width.



3
4
5
# File 'lib/tangerine/backlot/video.rb', line 3

def width
  @width
end

Class Method Details

.order_videos!(videos, embed_codes) ⇒ Object



56
57
58
59
60
61
62
# File 'lib/tangerine/backlot/video.rb', line 56

def self.order_videos!(videos, embed_codes)
  ordered = []
  embed_codes.each do |code|
    ordered << videos.select { |video| video.embed_code == code }
  end
  ordered.flatten
end

.where(options) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/tangerine/backlot/video.rb', line 43

def self.where(options)
  # FYI
  # Adding 'status' => 'live' to the query string does not work!
  embed_codes = options[:embed_code].join(',')
  result      = Tangerine.query('embedCode' => embed_codes, 'fields' => 'labels,metadata')
  items       = result.parsed_response['list']['item']
  items       = Tangerine::Base.prepare_items(items)
  videos      = items.collect { |item| Tangerine::Video.new(item) }
  videos      = videos.reject { |video| video.status != 'live' }

  Tangerine::Video.order_videos!(videos, options[:embed_code])
end

Instance Method Details

#as_json(options = {}) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/tangerine/backlot/video.rb', line 64

def as_json(options = {})
  {:size => size,
   :title => title,
   :thumbnail => thumbnail,
   :content => content,
   :updated_at => updated_at,
   :embed_code => embed_code,
   :description => description,
   :length => length,
   :status => status,
   :uploaded_at => uploaded_at,
   :flight_start_time => flight_start_time,
   :width => width,
   :height => height,
   :labels => labels,
   :metadata => ,
   :stat => stat
  }
end

#player(options = {}) ⇒ Object



38
39
40
41
# File 'lib/tangerine/backlot/video.rb', line 38

def player(options={})
  options.merge!(:embed_code => embed_code, :width => width, :height => height)
  Tangerine::Player.new(options)
end