Module: Playapi::Validation::TwitterScraper

Defined in:
lib/playapi/validation/twitter_scraper.rb

Class Method Summary collapse

Class Method Details

.pkeysObject



7
8
9
10
11
12
13
14
15
16
# File 'lib/playapi/validation/twitter_scraper.rb', line 7

def pkeys
  @pkeys ||= [
    :name,
    :description,
    :client_id,
    :client_secret,
    :oauth_token,
    :oauth_token_secret
  ]
end

.validate(opts) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/playapi/validation/twitter_scraper.rb', line 18

def validate(opts)
  pkeys.each do |p|
    unless opts.include?(p)
      raise "#{p} must not be nil"
    end
  end
  opts.each do |field, value|
  	raise "Type should not be specified in options!" if field.to_s == "type"
    #next if value.nil?

    unless value.is_a?(String) || value.is_a?(Integer) || value.is_a?(Float)
      raise("Invalid #{value} specified: #{field} must be a string or a number") unless value == points
    end
  end
end