Class: Nanopop::Picture
- Inherits:
-
Object
show all
- Defined in:
- lib/nanopop/picture.rb
Constant Summary
collapse
- URL =
"#{Nanopop::ASSETS_URL}/tasks/%s/%s"
- AVATAR_URL =
"#{Nanopop::ASSETS_URL}/users/%s/%s"
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(ats) ⇒ Picture
Returns a new instance of Picture.
12
13
14
|
# File 'lib/nanopop/picture.rb', line 12
def initialize ats
@ats = ats
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, params = {}) ⇒ Object
58
59
60
|
# File 'lib/nanopop/picture.rb', line 58
def method_missing method, params={}
@ats[method]
end
|
Class Method Details
.latest(qty) ⇒ Object
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/nanopop/picture.rb', line 24
def self.latest qty
raise Nanopop::UndefinedToken unless Nanopop.configuration.token
response = fetch(:latest, numberOfPictures: qty)
doc = Nokogiri.XML(response)
doc.search('PictureLatest').map do |item|
ats = {}
item.element_children.each do |at|
key = at.name.scan(/_x003C_(.+)_x003E_k__BackingField/).flatten.first.underscore
value = at.text
ats[key.to_sym] = value
end
new(ats)
end
end
|
Instance Method Details
#avatar_url ⇒ Object
20
21
22
|
# File 'lib/nanopop/picture.rb', line 20
def avatar_url
AVATAR_URL % [adjust(user_id), user_picture_filename]
end
|
#url ⇒ Object
16
17
18
|
# File 'lib/nanopop/picture.rb', line 16
def url
URL % [adjust(task_id), picture_filename]
end
|