Class: MechWarrior::MechCell

Inherits:
Object
  • Object
show all
Includes:
Celluloid
Defined in:
lib/mech_warrior/mech_cell.rb

Constant Summary collapse

MECH_ERRORS =
[
  SocketError,
  Mechanize::ResponseCodeError,
  Mechanize::ResponseReadError,
  Mechanize::UnsupportedSchemeError
]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ MechCell

Returns a new instance of MechCell.



11
12
13
14
# File 'lib/mech_warrior/mech_cell.rb', line 11

def initialize(logger)
  @agent = Mechanize.new
  @logger = logger
end

Instance Attribute Details

#agentObject (readonly)

Returns the value of attribute agent.



4
5
6
# File 'lib/mech_warrior/mech_cell.rb', line 4

def agent
  @agent
end

#loggerObject (readonly)

Returns the value of attribute logger.



4
5
6
# File 'lib/mech_warrior/mech_cell.rb', line 4

def logger
  @logger
end

Instance Method Details

#get(url) ⇒ Object



16
17
18
19
20
# File 'lib/mech_warrior/mech_cell.rb', line 16

def get(url)
  agent.get(url)
rescue *MECH_ERRORS => e
  logger << "Caught Exception getting URL: #{url} -- #{e}\n"
end