module Pexels::Client::SearchFilters

Constants

COLORS
ORIENTATIONS
SIZES

Public Instance Methods

validate_color(color) click to toggle source
# File lib/pexels/client/search_filters.rb, line 22
def validate_color(color)
  return true unless color
  return true if COLORS.include?(color.to_s)
  return true if color.to_s =~ /\A#?(?:[0-9a-f]{3}){1,2}\z/i

  raise ArgumentError, "`color` must be one of #{COLORS.join(', ')} or a valid hex code."
end
validate_orientation(orientation) click to toggle source
# File lib/pexels/client/search_filters.rb, line 8
def validate_orientation(orientation)
  return true unless orientation
  return true if ORIENTATIONS.include?(orientation.to_s)

  raise ArgumentError, "`orientation` must be one of #{ORIENTATIONS.join(', ')}."
end
validate_size(size) click to toggle source
# File lib/pexels/client/search_filters.rb, line 15
def validate_size(size)
  return true unless size
  return true if SIZES.include?(size.to_s)

  raise ArgumentError, "`size` must be one of #{SIZES.join(', ')}."
end