Class: ParentVUE::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/parentvue/service.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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(options = {})
  @mechanize = Mechanize.new

  @login_url = options[:login_url]

  uri = URI.parse(@login_url)
  @base_url = "#{uri.scheme}://#{uri.host}"
end

Instance Attribute Details

#base_urlObject (readonly)

Returns the value of attribute base_url.



7
8
9
# File 'lib/parentvue/service.rb', line 7

def base_url
  @base_url
end

#mechanizeObject (readonly)

Returns the value of attribute mechanize.



6
7
8
# File 'lib/parentvue/service.rb', line 6

def mechanize
  @mechanize
end

#studentsObject (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_pageObject



19
20
21
# File 'lib/parentvue/service.rb', line 19

def 
  @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 (username, password)
   = .link_with(text: /ParentVUE/)
   = .click

   = (, username, password)

  return false if .at '#ctl00_USER_ERROR'

  scrape_students()

  return 
end