Class: RussianPost::Tracking
- Inherits:
-
Object
- Object
- RussianPost::Tracking
- Defined in:
- lib/russian_post/tracking.rb
Constant Summary collapse
- TRACKING_PAGE =
'http://www.russianpost.ru/rp/servise/ru/home/postuslug/trackingpo'
- COLUMNS =
[:type, :date, :zip_code, :location, :message, :weight, :declared_cost, :delivery_cash, :destination_zip_code, :destination_location]
Instance Attribute Summary collapse
-
#agent ⇒ Object
readonly
Returns the value of attribute agent.
-
#barcode ⇒ Object
readonly
Returns the value of attribute barcode.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(tracking_code, options = {}) ⇒ Tracking
constructor
A new instance of Tracking.
- #track ⇒ Object
Constructor Details
#initialize(tracking_code, options = {}) ⇒ Tracking
Returns a new instance of Tracking.
15 16 17 18 19 |
# File 'lib/russian_post/tracking.rb', line 15 def initialize(tracking_code, = {}) @barcode = tracking_code.strip.upcase @agent = Mechanize.new @options = || {} end |
Instance Attribute Details
#agent ⇒ Object (readonly)
Returns the value of attribute agent.
9 10 11 |
# File 'lib/russian_post/tracking.rb', line 9 def agent @agent end |
#barcode ⇒ Object (readonly)
Returns the value of attribute barcode.
9 10 11 |
# File 'lib/russian_post/tracking.rb', line 9 def @barcode end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
9 10 11 |
# File 'lib/russian_post/tracking.rb', line 9 def @options end |
Instance Method Details
#track ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/russian_post/tracking.rb', line 21 def track initial_page = fetch_initial_page tracking_page = fetch_tracking_data(initial_page) check_validity!(tracking_page) parse_tracking_table(tracking_table(tracking_page)) end |