class RandomYiff::E621

Attributes

post[R]
post_uri[R]

Public Class Methods

new() { |self| ... } click to toggle source
# File lib/random_yiff/e621.rb, line 13
def initialize
  @post_uri = self.class.post_uri
  @post = JSON.load(Net::HTTP.get(post_uri))
  yield self if block_given?
end
post_uri() click to toggle source
# File lib/random_yiff/e621.rb, line 6
def self.post_uri
  res = Net::HTTP.get_response(URI('https://e621.net/post/random'))
  URI(res['location'] + '?format=json')
end

Public Instance Methods

file() click to toggle source
# File lib/random_yiff/e621.rb, line 27
def file
  @file ||= Net::HTTP.get(file_uri)
end
file_name() click to toggle source
# File lib/random_yiff/e621.rb, line 23
def file_name
  @file_name ||= "#{md5}.#{file_ext}"
end
file_uri() click to toggle source
# File lib/random_yiff/e621.rb, line 19
def file_uri
  @file_uri ||= URI(file_url)
end
method_missing(m, *args, &block) click to toggle source
Calls superclass method
# File lib/random_yiff/e621.rb, line 35
def method_missing(m, *args, &block)
  post["#{m}"] || super(m, *args, &block)
end
source() click to toggle source
# File lib/random_yiff/e621.rb, line 31
def source
  @source ||= post['source'] || 'Unknown'
end