Class: MechWarrior::MechCell
- Inherits:
-
Object
- Object
- MechWarrior::MechCell
- 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
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #get(url) ⇒ Object
-
#initialize(logger) ⇒ MechCell
constructor
A new instance of MechCell.
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
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
4 5 6 |
# File 'lib/mech_warrior/mech_cell.rb', line 4 def agent @agent end |
#logger ⇒ Object (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 |