Class: ParentVUE::Service
- Inherits:
-
Object
- Object
- ParentVUE::Service
- Defined in:
- lib/parentvue/service.rb
Instance Attribute Summary collapse
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
-
#mechanize ⇒ Object
readonly
Returns the value of attribute mechanize.
-
#students ⇒ Object
readonly
Returns the value of attribute students.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Service
constructor
A new instance of Service.
- #main_login_page ⇒ Object
- #parent_sign_in(username, password) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Service
Returns a new instance of Service.
10 11 12 13 14 15 16 17 |
# File 'lib/parentvue/service.rb', line 10 def initialize( = {}) @mechanize = Mechanize.new @login_url = [:login_url] uri = URI.parse(@login_url) @base_url = "#{uri.scheme}://#{uri.host}" end |
Instance Attribute Details
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
7 8 9 |
# File 'lib/parentvue/service.rb', line 7 def base_url @base_url end |
#mechanize ⇒ Object (readonly)
Returns the value of attribute mechanize.
6 7 8 |
# File 'lib/parentvue/service.rb', line 6 def mechanize @mechanize end |
#students ⇒ Object (readonly)
Returns the value of attribute students.
8 9 10 |
# File 'lib/parentvue/service.rb', line 8 def students @students end |
Instance Method Details
#main_login_page ⇒ Object
19 20 21 |
# File 'lib/parentvue/service.rb', line 19 def main_login_page @mechanize.get(@login_url) end |
#parent_sign_in(username, password) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/parentvue/service.rb', line 23 def parent_sign_in(username, password) parent_login_link = main_login_page.link_with(text: /ParentVUE/) login_page = parent_login_link.click post_login_page = login_with_credentials(login_page, username, password) return false if post_login_page.at '#ctl00_USER_ERROR' scrape_students(post_login_page) return post_login_page end |