Class: Ruby34
- Inherits:
-
Object
- Object
- Ruby34
- Defined in:
- lib/ruby34.rb
Class Method Summary collapse
-
.hai ⇒ Object
Basically just a test function.
-
.request(limit: nil, json: nil, tags: nil, id: nil) ⇒ Object
Make a request to the Rule34 API.
-
.request_comments(id: nil) ⇒ Object
Get the comments for a specific post.
Class Method Details
.hai ⇒ Object
Basically just a test function
6 7 8 |
# File 'lib/ruby34.rb', line 6 def self.hai puts "Haiii!! (from Ruby34 :3)" end |
.request(limit: nil, json: nil, tags: nil, id: nil) ⇒ Object
Make a request to the Rule34 API
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/ruby34.rb', line 11 def self.request(limit: nil, json: nil, tags: nil, id: nil) # See API reference here: https://api.rule34.xxx/index.php base_uri = "https://api.rule34.xxx/index.php?page=dapi&s=post&q=index" base_uri << "&limit=" << limit if limit != nil base_uri << "&json=1" if json == true base_uri << "&tags=" << .join('+').to_s if != nil base_uri << "&id=" << id.to_s if id != nil uri = URI(base_uri) Net::HTTP.get(uri) end |
.request_comments(id: nil) ⇒ Object
Get the comments for a specific post
23 24 25 26 27 28 |
# File 'lib/ruby34.rb', line 23 def self.request_comments(id: nil) # for whatever reason, the rule34 api doesn't allow json for comments >~< base_uri = "https://api.rule34.xxx/index.php?page=dapi&s=comment&q=index&post_id=" << id.to_s uri = URI(base_uri) Net::HTTP.get(uri) end |