Class: Identiconify::Identicon

Inherits:
Object
  • Object
show all
Defined in:
lib/identiconify.rb

Constant Summary collapse

DEFAULT_HASH_PROVIDER =
->(string) {
  Digest::SHA1.hexdigest(string).to_i(16)
}

Instance Method Summary collapse

Constructor Details

#initialize(string, options = {}) ⇒ Identicon

Returns a new instance of Identicon.



11
12
13
14
15
16
# File 'lib/identiconify.rb', line 11

def initialize(string, options={})
  @string = string
  @size = options.fetch(:size) { 250 }
  @colors = options.fetch(:colors) { :default }.to_sym
  @hash_provider = options.fetch(:hash_provider) { DEFAULT_HASH_PROVIDER }
end

Instance Method Details

#to_png_blobObject



18
19
20
# File 'lib/identiconify.rb', line 18

def to_png_blob
  render.to_blob :fast_rgba
end