Class: Stellar::Members::Photo
- Inherits:
-
Object
- Object
- Stellar::Members::Photo
- Defined in:
- lib/stellar/members.rb
Overview
Information about a member’s photo
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Generic Stellar client used to make requests.
-
#course ⇒ Object
readonly
The course this member belongs to.
-
#email ⇒ Object
readonly
The member’s e-mail.
-
#name ⇒ Object
readonly
The member’s full name.
-
#url ⇒ Object
readonly
URL of the member’s photo.
Instance Method Summary collapse
-
#data ⇒ Object
The member’s photo bits.
-
#initialize(div, course) ⇒ Photo
constructor
Creates a Stellar client scoped to a student’s Gradebook page.
Constructor Details
#initialize(div, course) ⇒ Photo
Creates a Stellar client scoped to a student’s Gradebook page.
119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/stellar/members.rb', line 119 def initialize(div, course) @course = course @client = course.client unless img = div.css('img[src*="pictures"]').first raise ArgumentError, 'Invalid photo-listing <div>' end @url = URI.join div.document.url, img['src'].gsub('/half/', '/full/') unless mail_link = div.css('a[href*="mailto"]').first raise ArgumentError, 'Invalid photo-listing <div>' end @email = mail_link['href'].sub(/^mailto\:/, '') @name = mail_link.inner_text end |
Instance Attribute Details
#client ⇒ Object (readonly)
Generic Stellar client used to make requests.
111 112 113 |
# File 'lib/stellar/members.rb', line 111 def client @client end |
#course ⇒ Object (readonly)
The course this member belongs to.
108 109 110 |
# File 'lib/stellar/members.rb', line 108 def course @course end |
#email ⇒ Object (readonly)
The member’s e-mail.
102 103 104 |
# File 'lib/stellar/members.rb', line 102 def email @email end |
#name ⇒ Object (readonly)
The member’s full name.
99 100 101 |
# File 'lib/stellar/members.rb', line 99 def name @name end |
#url ⇒ Object (readonly)
URL of the member’s photo.
105 106 107 |
# File 'lib/stellar/members.rb', line 105 def url @url end |
Instance Method Details
#data ⇒ Object
The member’s photo bits.
135 136 137 |
# File 'lib/stellar/members.rb', line 135 def data @client.get_file @url end |