Class: Illiad::Webcirc
- Inherits:
-
Object
- Object
- Illiad::Webcirc
- Defined in:
- lib/illiad/webcirc.rb
Instance Method Summary collapse
- #charge!(id) ⇒ Object
- #connect ⇒ Object
- #discharge!(id) ⇒ Object
-
#initialize(url, username, password) ⇒ Webcirc
constructor
A new instance of Webcirc.
Constructor Details
#initialize(url, username, password) ⇒ Webcirc
Returns a new instance of Webcirc.
6 7 8 9 10 11 |
# File 'lib/illiad/webcirc.rb', line 6 def initialize(url, username, password) @url = url @username = username @password = password @conn = Mechanize.new end |
Instance Method Details
#charge!(id) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/illiad/webcirc.rb', line 28 def charge!(id) page = @conn.get(@url + '/Default.aspx') page = page.form('aspnetForm') do |f| f['ctl00$TextBoxCheckOutTransaction'] = id end. page.form('aspnetForm').(:value => "Check Out") msg = page.at("#ctl00_UpdatePanelStatusMessages .failure, #ctl00_UpdatePanelStatusMessages .success, #ctl00_UpdatePanelStatusMessages .warning").inner_html raise msg if page.at("#ctl00_UpdatePanelStatusMessages .success").nil? true end |
#connect ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/illiad/webcirc.rb', line 13 def connect # Load Illiad Web Circulation page = @conn.get(@url + '/Logon.aspx') # Select, fill in, and submit the logon form. page = page.form('formLogon') do |f| f.TextBoxUsername = @username f.TextBoxPassword = @password end. # A successful login will redirect to /illiad/WebCirc/Default.aspx # A failed login will return to /illiadWebCirc/Logon.aspx page.uri.request_uri == '/illiad/WebCirc/Default.aspx' end |
#discharge!(id) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/illiad/webcirc.rb', line 41 def discharge!(id) page = @conn.get(@url + '/Default.aspx') page = page.form('aspnetForm') do |f| f['ctl00$TextBoxCheckInTransaction'] = id end. page.form('aspnetForm').(:value => "Check In") msg = page.at("#ctl00_UpdatePanelStatusMessages .failure, #ctl00_UpdatePanelStatusMessages .success, #ctl00_UpdatePanelStatusMessages .warning").inner_html raise msg if page.at("#ctl00_UpdatePanelStatusMessages .success").nil? true end |