Class: Tiledenticon

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

Instance Method Summary collapse

Constructor Details

#initialize(out_folder) ⇒ Tiledenticon

Wrapper for the classes defined in this library



8
9
10
11
12
13
14
15
16
17
# File 'lib/tiledenticon.rb', line 8

def initialize out_folder
  @out_folder = out_folder
	
	# Check valid directory
	unless File.directory?(out_folder)
FileUtils.mkdir_p(out_folder)
puts "Tiledenticon: Created directory #{out_folder}"
	end
	
end

Instance Method Details

#create(str) ⇒ Object



19
20
21
22
23
24
25
26
27
# File 'lib/tiledenticon.rb', line 19

def create str
  # Create a new md5 hasher and feed in the input string
  md5 = Digest::MD5.new
  md5 << str
  hash = md5.hexdigest
  hr = Hashrander.new hash
	
  fromHashrander "#{@out_folder}/#{str}.png", hr
end