class Faker::Avatar
def image(slug: nil, size: '300x300', format: 'png', set: 'set1', bgset: nil)
-
(String)
- A robohash.org URL
Parameters:
-
bgset
(String, nil
) -- The background set to use -
set
(String
) -- The avatar set to use -
format
(String
) -- The image file format -
size
(String
) -- image size in pixels, in the format of 'AxB' -
slug
(String, nil
) --
def image(slug: nil, size: '300x300', format: 'png', set: 'set1', bgset: nil) raise ArgumentError, 'Size should be specified in format 300x300' unless size =~ /^[0-9]+x[0-9]+$/ raise ArgumentError, "Supported formats are #{SUPPORTED_FORMATS.join(', ')}" unless SUPPORTED_FORMATS.include?(format) slug ||= Faker::Lorem.words.join bgset_query = "&bgset=#{bgset}" if bgset "https://robohash.org/#{slug}.#{format}?size=#{size}&set=#{set}#{bgset_query}" end