Class: SearchApi::GoogleImagesOptions

Inherits:
Object
  • Object
show all
Includes:
DynamicSchema::Definable, Helpers
Defined in:
lib/searchapi/google_images_options.rb

Constant Summary collapse

DEVICES =
%w[ desktop mobile tablet ]
SAFE_SEARCH =
%w[ active off ]
SIZES =
%w[ large medium icon larger_than_400x300 larger_than_640x480 larger_than_800x600
larger_than_1024x768 larger_than_2mp larger_than_4mp larger_than_6mp
larger_than_8mp larger_than_12mp larger_than_15mp larger_than_20mp
larger_than_40mp larger_than_70mp ]
COLORS =
%w[ black_and_white color transparent red orange yellow green teal blue
purple pink white gray black brown ]
IMAGE_TYPES =
%w[ clipart line_drawing gif face photo ]
TIME_PERIODS =
%w[ last_hour last_day last_week last_month last_year ]
USAGE_RIGHTS =
%w[ creative_commons_licenses commercial_or_other_licenses ]
ASPECT_RATIOS =
%w[ square tall wide panoramic ]
NORMALIZE_DOWNCASE =
->(v) { v.to_s.downcase }

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Helpers

#string_camelize

Constructor Details

#initialize(options = {}, api_options: nil) ⇒ GoogleImagesOptions



52
53
54
55
# File 'lib/searchapi/google_images_options.rb', line 52

def initialize( options = {}, api_options: nil )
  @options = self.class.builder.build( options || {} )
  @options = api_options.merge( @options ) if api_options
end

Class Method Details

.build(options = nil, &block) ⇒ Object



44
45
46
# File 'lib/searchapi/google_images_options.rb', line 44

def self.build( options = nil, &block )
  new( api_options: builder.build( options, &block ) )
end

.build!(options = nil, &block) ⇒ Object



48
49
50
# File 'lib/searchapi/google_images_options.rb', line 48

def self.build!( options = nil, &block )
  new( api_options: builder.build!( options, &block ) )
end

Instance Method Details

#to_hObject



57
58
59
60
61
# File 'lib/searchapi/google_images_options.rb', line 57

def to_h
  result = @options.to_h
  result[ :engine ] = 'google_images'
  result
end