Class: Shelbytv::User
- Inherits:
-
Object
show all
- Defined in:
- lib/shelbytv/user.rb
Constant Summary
collapse
- FIELDS =
[ :name,
:nickname,
:total_videos_played,
:user_image ]
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(shelbytv, json) ⇒ User
10
11
12
|
# File 'lib/shelbytv/user.rb', line 10
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
28
29
30
31
32
33
34
|
# File 'lib/shelbytv/user.rb', line 28
def method_missing(method_name, *args)
if FIELDS.include?(method_name)
@json[method_name.to_s]
else
super
end
end
|
Instance Attribute Details
#json ⇒ Object
Returns the value of attribute json.
8
9
10
|
# File 'lib/shelbytv/user.rb', line 8
def json
@json
end
|
Instance Method Details
#channels(options = {}) ⇒ Object
22
23
24
25
26
|
# File 'lib/shelbytv/user.rb', line 22
def channels(options={})
@shelbytv.get("channels.json", options).map do |item|
Shelbytv::Channel.new(@shelbytv, item)
end
end
|
#created_at ⇒ Object
18
19
20
|
# File 'lib/shelbytv/user.rb', line 18
def created_at
Time.parse(@json['created_at'])
end
|
#id ⇒ Object
14
15
16
|
# File 'lib/shelbytv/user.rb', line 14
def id
@json['_id']
end
|
#profile_image ⇒ Object
36
37
38
|
# File 'lib/shelbytv/user.rb', line 36
def profile_image
user_image
end
|