Module: Google::Search::SafetyLevel

Included in:
Image, Web
Defined in:
lib/google-search/search/mixins/safety_level.rb

Constant Summary collapse

SAFETY_LEVELS =

– Constants ++

:active, :moderate, :off

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#safety_levelObject

Safety level:

- :active | :high
- :moderate | :medium
- :off

20
21
22
# File 'lib/google-search/search/mixins/safety_level.rb', line 20

def safety_level
  @safety_level
end

Instance Method Details

#get_uri_paramsObject

:nodoc:


31
32
33
34
35
36
37
# File 'lib/google-search/search/mixins/safety_level.rb', line 31

def get_uri_params
  @safety_level = :off if @safety_level == :none
  @safety_level = :moderate if @safety_level == :medium
  @safety_level = :active if @safety_level == :high
  validate(:safety_level) { |level| level.nil? || SAFETY_LEVELS.include?(level) }
  super + [[:safe, safety_level]]
end

#initialize(options = {}, &block) ⇒ Object

:nodoc:


24
25
26
27
# File 'lib/google-search/search/mixins/safety_level.rb', line 24

def initialize options = {}, &block
  @safety_level = options.delete :safety_level
  super
end