Class: Tangerine::Channel

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Base

all, find, finder, #initialize, prepare_items

Constructor Details

This class inherits a constructor from Tangerine::Base

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



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

def description
  @description
end

#embed_codeObject

Returns the value of attribute embed_code.



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

def embed_code
  @embed_code
end

#lengthObject

Returns the value of attribute length.



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

def length
  @length
end

#sizeObject

Returns the value of attribute size.



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

def size
  @size
end

#statusObject

Returns the value of attribute status.



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

def status
  @status
end

#thumbnailObject

Returns the value of attribute thumbnail.



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

def thumbnail
  @thumbnail
end

#titleObject

Returns the value of attribute title.



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

def title
  @title
end

#updated_atObject

Returns the value of attribute updated_at.



3
4
5
# File 'lib/tangerine/backlot/channel.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/channel.rb', line 3

def uploaded_at
  @uploaded_at
end

Instance Method Details

#as_json(options = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/tangerine/backlot/channel.rb', line 25

def as_json(options = {})
  # TODO: Figure out why rails needs this to be called so badly
  vids = videos

  {:size => size,
   :title => title,
   :thumbnail => thumbnail,
   :updated_at => updated_at,
   :embed_code => embed_code,
   :description => description,
   :length => length,
   :status => status,
   :uploaded_at => uploaded_at,
   :videos => vids
  }
end

#videosObject



17
18
19
20
21
22
23
# File 'lib/tangerine/backlot/channel.rb', line 17

def videos
  channel = Tangerine::Backlot::API.get('/channels', 'mode' => 'list', 'channelEmbedCode' => embed_code)
  items = channel.parsed_response['channel']['item']
  items = Tangerine::Base.prepare_items(items)
  embed_codes = items.collect { |item| item['embedCode'] }
  Tangerine::Video.where(:embed_code => embed_codes)
end