Class: Google::Search::Image
- Inherits:
-
Google::Search
- Object
- Google::Search
- Google::Search::Image
- Includes:
- SafetyLevel
- Defined in:
- lib/google-search/search/image.rb
Constant Summary collapse
- SIZES =
– Constants ++
:icon, :small, :medium, :large, :xlarge, :xxlarge, :huge
- TYPES =
:face, :photo, :clipart, :lineart
- EXTENSIONS =
:jpg, :png, :gif, :bmp
Constants included from SafetyLevel
Constants inherited from Google::Search
Instance Attribute Summary collapse
-
#color ⇒ Object
Image color.
-
#file_type ⇒ Object
File type:.
-
#image_size ⇒ Object
Image size:.
-
#image_type ⇒ Object
Image type:.
-
#uri ⇒ Object
Specific uri to fetch images from.
Attributes included from SafetyLevel
Attributes inherited from Google::Search
#api_key, #language, #offset, #options, #query, #sent, #size, #type, #version
Instance Method Summary collapse
-
#get_uri_params ⇒ Object
:nodoc:.
-
#initialize(options = {}, &block) ⇒ Image
constructor
:nodoc:.
Methods inherited from Google::Search
#all_items, #each_item, #each_response, #get_hash, #get_raw, #get_response, #get_uri, json_decode, #next, size_for, url_encode, #validate
Constructor Details
#initialize(options = {}, &block) ⇒ Image
:nodoc:
68 69 70 71 72 73 74 |
# File 'lib/google-search/search/image.rb', line 68 def initialize = {}, &block @color = .delete :color @image_size = .delete :image_size @image_type = .delete :image_type @file_type = .delete :file_type super end |
Instance Attribute Details
#color ⇒ Object
Image color.
59 60 61 |
# File 'lib/google-search/search/image.rb', line 59 def color @color end |
#file_type ⇒ Object
File type:
- :jpg
- :gif
- :png
- :bmp
54 55 56 |
# File 'lib/google-search/search/image.rb', line 54 def file_type @file_type end |
#image_size ⇒ Object
Image size:
- :icon
- :small
- :medium
- :large
- :xlarge
- :xxlarge
- :huge
32 33 34 |
# File 'lib/google-search/search/image.rb', line 32 def image_size @image_size end |
#image_type ⇒ Object
Image type:
- :face
- :photo
- :clipart
- :lineart
43 44 45 |
# File 'lib/google-search/search/image.rb', line 43 def image_type @image_type end |
#uri ⇒ Object
Specific uri to fetch images from.
64 65 66 |
# File 'lib/google-search/search/image.rb', line 64 def uri @uri end |
Instance Method Details
#get_uri_params ⇒ Object
:nodoc:
78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/google-search/search/image.rb', line 78 def get_uri_params validate(:image_size) { |size| size.nil? || size.is_a?(Array) || SIZES.include?(size) } validate(:image_type) { |type| type.nil? || TYPES.include?(type) } validate(:file_type) { |ext| ext.nil? || EXTENSIONS.include?(ext) } super + [ [:safe, safety_level], [:imgsz, image_size.is_a?(Array) ? image_size.join('|') : image_size], [:imgcolor, color], [:imgtype, image_type], [:as_filetype, file_type], [:as_sitesearch, uri] ] end |