Module: Robohash

Defined in:
lib/robohash.rb,
lib/robohash/version.rb

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.default_directoryObject



11
# File 'lib/robohash.rb', line 11

def default_directory; @default_directory end

.default_directory=(v) ⇒ Object



12
# File 'lib/robohash.rb', line 12

def default_directory= v; @default_directory = v end

.default_numObject



9
# File 'lib/robohash.rb', line 9

def default_num; @default_num end

.default_num=(v) ⇒ Object



10
# File 'lib/robohash.rb', line 10

def default_num= v; @default_num = v end

.get_imagesObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/robohash.rb', line 15

def self.get_images
  if Dir.exists? @default_directory
    self.Delete_directory
  else
    Dir.mkdir(@default_directory)
  end
  (1..default_num).each{
    o =  [('a'..'z'),('A'..'Z')].map{|i| i.to_a}.flatten;
    string  =  (0..10).map{ o[rand(o.length)]  }.join;
    image = HTTParty.get "http://robohash.org/#{string}.png"
    open( "#{@default_directory}/#{string}.png", 'wb' ) { |file|
        file.write(image.body)
      }
  }
end

.VersionObject



13
# File 'lib/robohash.rb', line 13

def Version; self::VERSION end