Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add YARD docs to Faker::Placeholdit #2009

Merged
merged 1 commit into from May 22, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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