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, generate, letterify, method_missing, numerify, parse, rand, rand_in_range, regexify, resolve, respond_to_missing?, sample, shuffle, shuffle!, translate, unique, with_locale

Class Method Details

.colorized_image(size: '300x300', color: 'red', search_terms: ['all'], match_all: false) ⇒ String

Produces a random colorized image URL from loremflickr.com.

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:

Raises:

  • (ArgumentError)


89
90
91
92
93
94
# File 'lib/faker/default/lorem_flickr.rb', line 89

def colorized_image(size: '300x300', color: 'red', search_terms: ['all'], match_all: false)
  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(size: '300x300', search_terms: ['all'], match_all: false) ⇒ String

Produces a random grayscale image URL from loremflickr.com.

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:

Raises:

  • (ArgumentError)


44
45
46
47
48
# File 'lib/faker/default/lorem_flickr.rb', line 44

def grayscale_image(size: '300x300', search_terms: ['all'], match_all: false)
  raise ArgumentError, 'Search terms must be specified for grayscale images' unless search_terms.any?

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

.image(size: '300x300', search_terms: [], match_all: false) ⇒ String

Produces a random image URL from loremflickr.com.

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:



24
25
26
# File 'lib/faker/default/lorem_flickr.rb', line 24

def image(size: '300x300', search_terms: [], match_all: false)
  build_url(size, nil, search_terms, match_all)
end

.pixelated_image(size: '300x300', search_terms: ['all'], match_all: false) ⇒ String

Produces a random pixelated image URL from loremflickr.com.

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:

Raises:

  • (ArgumentError)


66
67
68
69
70
# File 'lib/faker/default/lorem_flickr.rb', line 66

def pixelated_image(size: '300x300', search_terms: ['all'], match_all: false)
  raise ArgumentError, 'Search terms must be specified for pixelated images' unless search_terms.any?

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