Skip to content

Commit

Permalink
Add YARD docs to Faker::Placeholdit (#2009)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielTiringer committed May 22, 2020
1 parent ebd2af7 commit 4f2c416
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/faker/default/placeholdit.rb
Expand Up @@ -5,6 +5,27 @@ class Placeholdit < Base
class << self
SUPPORTED_FORMATS = %w[png jpg gif jpeg].freeze

##
# Produces a random placeholder image from https://placehold.it.
#
# @param size [String] Specifies the image's size, dimensions separated by 'x'.
# @param format [String] Specifies the image's extension.
# @param background_color [String, Symbol] Specifies the background color, either in hexadecimal format (without #) or as :random.
# @param text_color [String, Symbol] Specifies the text color, either in hexadecimal format (without #) or as :random.
# @param text [String] Specifies a custom text to be used.
# @return [String]
#
# @example
# # Keyword arguments: size, format, background_color, text_color, text
# Faker::Placeholdit.image #=> "https://placehold.it/300x300.png"
# Faker::Placeholdit.image(size: '50x50') #=> "https://placehold.it/50x50.png"
# Faker::Placeholdit.image(size: '50x50', format: 'jpg') #=> "https://placehold.it/50x50.jpg"
# Faker::Placeholdit.image(size: '50x50', format: 'gif', background_color: 'ffffff') #=> "https://placehold.it/50x50.gif/ffffff"
# Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: :random) #=> "https://placehold.it/50x50.jpeg/39eba7"
# Faker::Placeholdit.image(size: '50x50', format: 'jpeg', background_color: 'ffffff', text_color: '000') #=> "https://placehold.it/50x50.jpeg/ffffff/000"
# Faker::Placeholdit.image(size: '50x50', format: 'jpg', background_color: 'ffffff', text_color: '000', text: 'Some Custom Text') #=> "https://placehold.it/50x50.jpg/ffffff/000?text=Some Custom Text"
#
# @faker.version 1.6.0
# rubocop:disable Metrics/ParameterLists
def image(legacy_size = NOT_GIVEN, legacy_format = NOT_GIVEN, legacy_background_color = NOT_GIVEN, legacy_text_color = NOT_GIVEN, legacy_text = NOT_GIVEN, size: '300x300', format: 'png', background_color: nil, text_color: nil, text: nil)
# rubocop:enable Metrics/ParameterLists
Expand Down

0 comments on commit 4f2c416

Please sign in to comment.