Class: AMarmita::Orders::Base

Inherits:
ClientModule show all
Defined in:
lib/a_marmita/orders/base.rb

Instance Attribute Summary

Attributes inherited from ClientModule

#client

Instance Method Summary collapse

Methods inherited from ClientModule

#initialize

Constructor Details

This class inherits a constructor from AMarmita::ClientModule

Instance Method Details

#cancel(id, line) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/a_marmita/orders/base.rb', line 20

def cancel(id, line)
  return :bad_login if cant_log_in?
  
  server_response = get_page_body("http://www.amarmita.com/enc.php?op=9&e=#{id}&l=#{line}")

  server_response == "1" ? :ok : :error
end

#listObject



8
9
10
11
12
13
14
15
16
17
18
# File 'lib/a_marmita/orders/base.rb', line 8

def list
  return :bad_login if cant_log_in?

  page = get_page "http://www.amarmita.com/enc.php?op=7"
  
  return [] if page.body == '-1'

  content_rows = page.parser.css('table')[1].css('tr')
  
  content_rows.map { |row| Orders::Scrapper.new(row).scrap }.compact
end