Module: Robohash
- Defined in:
- lib/robohash.rb,
lib/robohash/version.rb
Constant Summary collapse
- VERSION =
"0.0.3"
Class Method Summary collapse
- .default_directory ⇒ Object
- .default_directory=(v) ⇒ Object
- .default_num ⇒ Object
- .default_num=(v) ⇒ Object
- .get_images ⇒ Object
- .Version ⇒ Object
Class Method Details
.default_directory ⇒ Object
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_num ⇒ Object
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_images ⇒ Object
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 |
.Version ⇒ Object
13 |
# File 'lib/robohash.rb', line 13 def Version; self::VERSION end |