Module: Pexels::Client::SearchFilters
Constant Summary collapse
- ORIENTATIONS =
%w(portrait landscape square).freeze
- SIZES =
%w(small medium large).freeze
- COLORS =
%w(red orange yellow green turquoise blue violet pink brown black gray white).freeze
Instance Method Summary collapse
- #validate_color(color) ⇒ Object
- #validate_orientation(orientation) ⇒ Object
- #validate_size(size) ⇒ Object
Instance Method Details
#validate_color(color) ⇒ Object
22 23 24 25 26 27 28 |
# 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) ⇒ Object
8 9 10 11 12 13 |
# 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 |