class FactoryHelper::Avatar

Constants

SUPPORTED_FORMATS

Public Class Methods

image(slug = nil, size = '300x300', format = 'png') click to toggle source
# File lib/factory-helper/avatar.rb, line 7
def image(slug = nil, size = '300x300', format = 'png')
  raise ArgumentError, "Size should be specified in format 300x300" unless size.match(/^[0-9]+x[0-9]+$/)
  raise ArgumentError, "Supported formats are #{SUPPORTED_FORMATS.join(', ')}" unless SUPPORTED_FORMATS.include?(format)
  slug ||= FactoryHelper::Lorem.words.join
  "http://robohash.org/#{slug}.#{format}?size=#{size}"
end