Module: Booru::API
- Included in:
- Client
- Defined in:
- lib/booru/api.rb,
lib/booru/api/tag.rb,
lib/booru/api/note.rb,
lib/booru/api/pool.rb,
lib/booru/api/post.rb,
lib/booru/api/user.rb,
lib/booru/api/wiki.rb,
lib/booru/api/forum.rb,
lib/booru/api/artist.rb,
lib/booru/api/comment.rb,
lib/booru/api/favorite.rb
Defined Under Namespace
Modules: Artist, Comment, Favorite, Forum, Note, Pool, Post, Tag, User, Wiki
Instance Method Summary
collapse
Instance Method Details
22
23
24
|
# File 'lib/booru/api.rb', line 22
def formatted_path(path)
[path, @format].compact.join('.')
end
|
#parse(response) ⇒ Object
5
6
7
8
9
10
11
12
13
14
|
# File 'lib/booru/api.rb', line 5
def parse(response)
case @format
when :json
JSON.parse(response)
when :xml
Nori.parse(response)
else
response
end
end
|
#query_string(path, options = {}, formatted = false) ⇒ Object
16
17
18
19
20
|
# File 'lib/booru/api.rb', line 16
def query_string(path, options = {}, formatted = false)
params = options.map { |k,v| "#{k}=#{v}" }.join("&")
path = formatted_path(path) unless formatted
path += "?#{params}" unless params.empty?
end
|