Module: FFaker::Avatar

Extended by:
Avatar, ModuleUtils
Included in:
Avatar
Defined in:
lib/ffaker/avatar.rb

Constant Summary collapse

SUPPORTED_FORMATS =
%w[png jpg bmp].freeze

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, luhn_check, underscore, unique

Methods included from RandomUtils

#fetch_sample, #rand, #shuffle

Instance Method Details

#image(*args, slug: nil, size: '300x300', format: 'png', bgset: nil) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/ffaker/avatar.rb', line 10

def image(*args, slug: nil, size: '300x300', format: 'png', bgset: nil)
  if args.any?
    warn "Positional arguments for Avatar##{__method__} are deprecated. Please use keyword arguments."
    slug = args[0]
    size = args[1] if args.size > 1
    format = args[2] if args.size > 2
    bgset = args[3] if args.size > 3
  end

  check_passed_params(size, format, bgset)
  slug ||= FFaker::Lorem.words.join
  "https://robohash.org/#{slug}.#{format}?size=#{size}#{"&bgset=bg#{bgset}" if bgset}"
end