Class: Source::Illiad::Record
- Inherits:
-
Object
- Object
- Source::Illiad::Record
- Defined in:
- lib/nostos-source-illiad/record.rb
Instance Attribute Summary collapse
-
#due_date ⇒ Object
readonly
Returns the value of attribute due_date.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #charge! ⇒ Object
- #charged?(force = false) ⇒ Boolean
-
#initialize(attributes = {}) ⇒ Record
constructor
A new instance of Record.
Constructor Details
#initialize(attributes = {}) ⇒ Record
Returns a new instance of Record.
7 8 9 10 11 12 |
# File 'lib/nostos-source-illiad/record.rb', line 7 def initialize(attributes = {}) @id = attributes[:id] @title = attributes[:title] @charged = attributes[:charged] @due_date = attributes[:due_date] end |
Instance Attribute Details
#due_date ⇒ Object
Returns the value of attribute due_date.
14 15 16 |
# File 'lib/nostos-source-illiad/record.rb', line 14 def due_date @due_date end |
#id ⇒ Object
Returns the value of attribute id.
14 15 16 |
# File 'lib/nostos-source-illiad/record.rb', line 14 def id @id end |
#title ⇒ Object
Returns the value of attribute title.
14 15 16 |
# File 'lib/nostos-source-illiad/record.rb', line 14 def title @title end |
Instance Method Details
#charge! ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/nostos-source-illiad/record.rb', line 26 def charge! # Create a new mechanize object agent = Mechanize.new# { |a| a.log = Logger.new(STDERR) } # Load Illiad Web Circulation page = agent.get(Source::Illiad.config.webcirc['url']) # Select, fill in, and submit the logon form. page = page.form('formLogon') do |f| f.TextBoxUsername = Source::Illiad.config.webcirc['username'] f.TextBoxPassword = Source::Illiad.config.webcirc['password'] end. # Mechanize::ResponseCodeError - 500 => Net::HTTPInternalServerError: # catch these and try again. page = page.form('aspnetForm') do |f| f['ctl00$TextBoxCheckOutTransaction'] = @id end. if !page.at("#ctl00_UpdatePanelStatusMessages .success").nil? type = 'success' elsif !page.at("#ctl00_UpdatePanelStatusMessages .warning").nil? type = 'failure' else type = 'error' end puts "#{@id} - #{@title}" puts page.at("#ctl00_UpdatePanelStatusMessages .failure, #ctl00_UpdatePanelStatusMessages .success, #ctl00_UpdatePanelStatusMessages .warning").inner_html end |
#charged?(force = false) ⇒ Boolean
16 17 18 19 20 21 22 23 24 |
# File 'lib/nostos-source-illiad/record.rb', line 16 def charged?(force = false) if force then t = ::Illiad::AR::Transaction.find(@id) @due_date = t.due_date @charged = t.charged? end @charged end |