Class: Squeegee::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/squeegee/base.rb

Direct Known Subclasses

Account, BSkyB, BritishGas, OrangeUK

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#agent=(value) ⇒ Object (writeonly)

Sets the attribute agent

Parameters:

  • value

    the value to set the attribute agent to.



3
4
5
# File 'lib/squeegee/base.rb', line 3

def agent=(value)
  @agent = value
end

#amount=(value) ⇒ Object (writeonly)

Sets the attribute amount

Parameters:

  • value

    the value to set the attribute amount to.



3
4
5
# File 'lib/squeegee/base.rb', line 3

def amount=(value)
  @amount = value
end

#due_at=(value) ⇒ Object (writeonly)

Sets the attribute due_at

Parameters:

  • value

    the value to set the attribute due_at to.



3
4
5
# File 'lib/squeegee/base.rb', line 3

def due_at=(value)
  @due_at = value
end

#keys=(value) ⇒ Object (writeonly)

Sets the attribute keys

Parameters:

  • value

    the value to set the attribute keys to.



3
4
5
# File 'lib/squeegee/base.rb', line 3

def keys=(value)
  @keys = value
end

#paid=(value) ⇒ Object (writeonly)

Sets the attribute paid

Parameters:

  • value

    the value to set the attribute paid to.



3
4
5
# File 'lib/squeegee/base.rb', line 3

def paid=(value)
  @paid = value
end

Instance Method Details

#get(url) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/squeegee/base.rb', line 16

def get(url)
  @agent ||= Mechanize.new
  @agent.log = Logger.new 'squeegee.log'
  @agent.user_agent = "Mozilla/5.0 (Squeegee)"
  @agent.default_encoding = "utf8"
  @agent.agent.http.ssl_version = :SSLv3
  @agent.get(url)
end

#params(args) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/squeegee/base.rb', line 4

def params(args)
  missing_keys = []
  return unless defined? @keys
  @keys.each do |key|
    missing_keys << key unless args.has_key?(key.to_sym)
  end
  if missing_keys.any?
    raise Error::InvalidParams,
      "missing parameters #{missing_keys.map {|key| "`#{key}` "}.join}"
  end
end