Class: Shelbytv::Broadcast

Inherits:
Object
  • Object
show all
Defined in:
lib/shelbytv/broadcast.rb

Constant Summary collapse

FIELDS =
[ :channel_id,
:description,
:name,
:total_plays,
:user_id,
:user_nickname,
:user_thumbnail,
:video_description,
:video_id_at_provider,
:video_originator_user_image,
:video_originator_user_name,
:video_originator_user_nickname,
:video_player,
:video_provider_name,
:video_thumbnail_url,
:video_title,
:video_user_id,
:video_user_nickname,
:video_user_thumbnail,
:video_user_thumbnail,
:watched_by_owner ]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shelbytv, json) ⇒ Broadcast



27
28
29
# File 'lib/shelbytv/broadcast.rb', line 27

def initialize(shelbytv, json)
  @shelbytv, @json = shelbytv, json
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object



43
44
45
46
47
48
49
# File 'lib/shelbytv/broadcast.rb', line 43

def method_missing(method_name, *args)
  if FIELDS.include?(method_name)
    @json[method_name.to_s]
  else
    super
  end
end

Instance Attribute Details

#jsonObject (readonly)

Returns the value of attribute json.



25
26
27
# File 'lib/shelbytv/broadcast.rb', line 25

def json
  @json
end

Instance Method Details

#channelObject



35
36
37
# File 'lib/shelbytv/broadcast.rb', line 35

def channel
  @shelbytv.channels.find(channel_id)
end

#created_atObject



39
40
41
# File 'lib/shelbytv/broadcast.rb', line 39

def created_at
  Time.parse(@json['created_at'])
end

#idObject



31
32
33
# File 'lib/shelbytv/broadcast.rb', line 31

def id
  @json['_id']
end

#updated_atObject



51
52
53
# File 'lib/shelbytv/broadcast.rb', line 51

def updated_at
  Time.parse(@json['created_at'])
end

#userObject



55
56
57
# File 'lib/shelbytv/broadcast.rb', line 55

def user
  @shelbytv.users.find(user_id)
end

#watched_by_owner?Boolean



59
60
61
# File 'lib/shelbytv/broadcast.rb', line 59

def watched_by_owner?
  watched_by_owner
end