Class: Faker::LoremFlickr

Inherits:
Base
  • Object
show all
Defined in:
lib/faker/default/lorem_flickr.rb

Constant Summary collapse

SUPPORTED_COLORIZATIONS =
%w[red green blue].freeze

Constants inherited from Base

Base::LLetters, Base::Letters, Base::NOT_GIVEN, Base::Numbers, Base::ULetters

Class Method Summary collapse

Methods inherited from Base

bothify, disable_enforce_available_locales, fetch, fetch_all, flexible, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, translate, unique, with_locale

Class Method Details

.colorized_image(legacy_size = NOT_GIVEN, legacy_color = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', color: 'red', search_terms: ['all'], match_all: false) ⇒ String

Produces a random colorized image URL from loremflickr.com.

rubocop:disable Metrics/ParameterLists

Examples:

Faker::LoremFlickr.image #=> "https://loremflickr.com/red/300/300/all"
Faker::LoremFlickr.image(size: "50x60", color: 'blue') #=> "https://loremflickr.com/blue/50/60/all"
Faker::LoremFlickr.image(size: "50x60", color: 'blue', search_terms: ['sports']) #=> "https://loremflickr.com/blue/50/60/sports"
Faker::LoremFlickr.image(size: "50x60", color: 'blue', search_terms: ['sports', 'fitness']) #=> "https://loremflickr.com/blue/50/60/sports,fitness"
Faker::LoremFlickr.image(size: "50x60", color: 'blue', search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/blue/50/60/sports,fitness/all"

Parameters:

  • size (String) (defaults to: '300x300')

    Specifies the size of image to generate.

  • color (String) (defaults to: 'red')

    Specifies the color of image to generate.

  • search_terms (Array<String>) (defaults to: ['all'])

    Adds search terms to the image URL.

  • match_all (Boolean) (defaults to: false)

    Add “all” as part of the URL.

Returns:

  • (String)

Raises:

  • (ArgumentError)

Available since:

  • 1.9.0


114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/faker/default/lorem_flickr.rb', line 114

def colorized_image(legacy_size = NOT_GIVEN, legacy_color = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', color: 'red', search_terms: ['all'], match_all: false)
  # rubocop:enable Metrics/ParameterLists
  warn_for_deprecated_arguments do |keywords|
    keywords << :size if legacy_size != NOT_GIVEN
    keywords << :color if legacy_color != NOT_GIVEN
    keywords << :search_terms if legacy_search_terms != NOT_GIVEN
    keywords << :match_all if legacy_match_all != NOT_GIVEN
  end

  raise ArgumentError, 'Search terms must be specified for colorized images' unless search_terms.any?
  raise ArgumentError, "Supported colorizations are #{SUPPORTED_COLORIZATIONS.join(', ')}" unless SUPPORTED_COLORIZATIONS.include?(color)

  build_url(size, color, search_terms, match_all)
end

.grayscale_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false) ⇒ String

Produces a random grayscale image URL from loremflickr.com.

rubocop:disable Metrics/ParameterLists

Examples:

Faker::LoremFlickr.grayscale_image #=> "https://loremflickr.com/g/300/300/all"
Faker::LoremFlickr.grayscale_image(size: "50x60") #=> "https://loremflickr.com/g/50/60/all"
Faker::LoremFlickr.grayscale_image(size: "50x60", search_terms: ['sports']) #=> "https://loremflickr.com/g/50/60/sports"
Faker::LoremFlickr.grayscale_image(size: "50x60", search_terms: ['sports', 'fitness']) #=> "https://loremflickr.com/50/60/g/sports,fitness"
Faker::LoremFlickr.grayscale_image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/g/50/60/sports,fitness/all"

Parameters:

  • size (String) (defaults to: '300x300')

    Specifies the size of image to generate.

  • search_terms (Array<String>) (defaults to: ['all'])

    Adds search terms to the image URL.

  • match_all (Boolean) (defaults to: false)

    Add “all” as part of the URL.

Returns:

  • (String)

Raises:

  • (ArgumentError)

Available since:

  • 1.9.0


53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/faker/default/lorem_flickr.rb', line 53

def grayscale_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false)
  # rubocop:enable Metrics/ParameterLists
  warn_for_deprecated_arguments do |keywords|
    keywords << :size if legacy_size != NOT_GIVEN
    keywords << :search_terms if legacy_search_terms != NOT_GIVEN
    keywords << :match_all if legacy_match_all != NOT_GIVEN
  end

  raise ArgumentError, 'Search terms must be specified for grayscale images' unless search_terms.any?

  build_url(size, 'g', search_terms, match_all)
end

.image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: [], match_all: false) ⇒ String

Produces a random image URL from loremflickr.com.

rubocop:disable Metrics/ParameterLists

Examples:

Faker::LoremFlickr.image #=> "https://loremflickr.com/300/300"
Faker::LoremFlickr.image(size: "50x60") #=> "https://loremflickr.com/50/60"
Faker::LoremFlickr.image(size: "50x60", search_terms: ['sports']) #=> "https://loremflickr.com/50/60/sports"
Faker::LoremFlickr.image(size: "50x60", search_terms: ['sports', 'fitness']) #=> "https://loremflickr.com/50/60/sports,fitness"
Faker::LoremFlickr.image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/50/60/sports,fitness/all"

Parameters:

  • size (String) (defaults to: '300x300')

    Specifies the size of image to generate.

  • search_terms (Array<String>) (defaults to: [])

    Adds search terms to the image URL.

  • match_all (Boolean) (defaults to: false)

    Add “all” as part of the URL.

Returns:

  • (String)

Available since:

  • 1.9.0


25
26
27
28
29
30
31
32
33
34
# File 'lib/faker/default/lorem_flickr.rb', line 25

def image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: [], match_all: false)
  # rubocop:enable Metrics/ParameterLists
  warn_for_deprecated_arguments do |keywords|
    keywords << :size if legacy_size != NOT_GIVEN
    keywords << :search_terms if legacy_search_terms != NOT_GIVEN
    keywords << :match_all if legacy_match_all != NOT_GIVEN
  end

  build_url(size, nil, search_terms, match_all)
end

.pixelated_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false) ⇒ String

Produces a random pixelated image URL from loremflickr.com.

rubocop:disable Metrics/ParameterLists

Examples:

Faker::LoremFlickr.pixelated_image #=> "https://loremflickr.com/p/300/300/all"
Faker::LoremFlickr.pixelated_image(size: "50x60") #=> "https://loremflickr.com/p/50/60/all"
Faker::LoremFlickr.pixelated_image(size: "50x60", search_terms: ['sports']) #=> "https://loremflickr.com/p/50/60/sports"
Faker::LoremFlickr.pixelated_image(size: "50x60", search_terms: ['sports', 'fitness']) #=> "https://loremflickr.com/p/50/60/sports,fitness"
Faker::LoremFlickr.pixelated_image(size: "50x60", search_terms: ['sports', 'fitness'], match_all: true) #=> "https://loremflickr.com/p/50/60/sports,fitness/all"

Parameters:

  • size (String) (defaults to: '300x300')

    Specifies the size of image to generate.

  • search_terms (Array<String>) (defaults to: ['all'])

    Adds search terms to the image URL.

  • match_all (Boolean) (defaults to: false)

    Add “all” as part of the URL.

Returns:

  • (String)

Raises:

  • (ArgumentError)

Available since:

  • 1.9.0


83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/faker/default/lorem_flickr.rb', line 83

def pixelated_image(legacy_size = NOT_GIVEN, legacy_search_terms = NOT_GIVEN, legacy_match_all = NOT_GIVEN, size: '300x300', search_terms: ['all'], match_all: false)
  # rubocop:enable Metrics/ParameterLists
  warn_for_deprecated_arguments do |keywords|
    keywords << :size if legacy_size != NOT_GIVEN
    keywords << :search_terms if legacy_search_terms != NOT_GIVEN
    keywords << :match_all if legacy_match_all != NOT_GIVEN
  end

  raise ArgumentError, 'Search terms must be specified for pixelated images' unless search_terms.any?

  build_url(size, 'p', search_terms, match_all)
end