/
clip.rb
81 lines (62 loc) · 1.45 KB
/
clip.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
require "kippt/resource"
require "kippt/user"
require "kippt/list"
require "kippt/comments"
require "kippt/likes"
require "kippt/saves"
class Kippt::Clip
include Kippt::Resource
attributes :url_domain, :updated, :is_starred, :title,
:url, :notes, :created, :id, :resource_uri,
:type, :favicon_url, :app_url, :media,
:user => "Kippt::User", :via => "Kippt::Clip"
writable_attributes :is_favorite, :title, :url, :notes, :list
boolean_attributes :is_favorite
alias :is_starred :is_favorite
alias :is_starred= :is_favorite=
alias :starred? :favorite?
embedded_attributes :list => "Kippt::List"
def collection_resource_class
Kippt::Clips
end
def list_uri
if attributes.list.is_a? String
attributes.list
else
list.resource_uri
end
end
def comments
Kippt::Comments.new(client, self)
end
def all_comments_embedded?
comments_count == comments_data.size
end
def comments_count
attributes.comments["count"]
end
def comments_data
attributes.comments["data"]
end
def likes
Kippt::Likes.new(client, self)
end
def all_likes_embedded?
likes_count == likes_data.size
end
def likes_count
attributes.likes["count"]
end
def likes_data
attributes.likes["data"]
end
def saves
Kippt::Saves.new(client, self)
end
def saves_count
attributes.saves["count"]
end
def saves_data
attributes.saves["data"]
end
end