Method: Rubyhexagon::Image#initialize

Defined in:
lib/rubyhexagon/image.rb

#initialize(file) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializer for a File. This is not a Ruby file class, but an abstraction of e621 file information.

Parameters:

  • file (Hash)

    file information

Author:

  • Maxine Michalski

Since:

  • 1.0.0



53
54
55
56
57
58
59
60
61
62
63
# File 'lib/rubyhexagon/image.rb', line 53

def initialize(file)
  @url = URI.parse(file[:url])
  @md5 = File.basename(file[:url]).sub(/\.\w{3,4}$/, '')
  @ext = file[:ext]
  @width = file[:width].to_i
  @height = file[:height].to_i
  @size = file[:size].to_i
  @user_agent = { 'User-Agent' =>
                 "#{Rubyhexagon::NAME}/#{Rubyhexagon::VERSION} "\
                  '(by maxine_red on e621' }
end