Class: Stellar::Members::PhotoList
- Inherits:
-
Object
- Object
- Stellar::Members::PhotoList
- Defined in:
- lib/stellar/members.rb
Overview
Collection of member photos in a course’s Membership module.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Generic Stellar client used to make requests.
-
#course ⇒ Object
readonly
Client scoped to the Membership module supplying this list of photos.
Instance Method Summary collapse
-
#all ⇒ Array<Stellar::Members::Photo>
All member photos listed in this course’s Membership module.
-
#initialize(members) ⇒ PhotoList
constructor
Creates a list of member photos for a class.
-
#named(name) ⇒ Stellar::Members::Photo
A photo in the course’s Membership module.
-
#reload! ⇒ Stellar::Gradebook::StudentList
Reloads the contents of this student list.
-
#with_email(email) ⇒ Stellar::Members::Photo
A photo in the course’s Membership module.
Constructor Details
#initialize(members) ⇒ PhotoList
Creates a list of member photos for a class.
48 49 50 51 52 53 54 |
# File 'lib/stellar/members.rb', line 48 def initialize(members) @course = members.course @client = members.client @url = members.['Member Photos'] reload! end |
Instance Attribute Details
#client ⇒ Object (readonly)
Generic Stellar client used to make requests.
43 44 45 |
# File 'lib/stellar/members.rb', line 43 def client @client end |
#course ⇒ Object (readonly)
Client scoped to the Membership module supplying this list of photos.
40 41 42 |
# File 'lib/stellar/members.rb', line 40 def course @course end |
Instance Method Details
#all ⇒ Array<Stellar::Members::Photo>
All member photos listed in this course’s Membership module.
58 59 60 |
# File 'lib/stellar/members.rb', line 58 def all @photos end |
#named(name) ⇒ Stellar::Members::Photo
A photo in the course’s Membership module.
66 67 68 |
# File 'lib/stellar/members.rb', line 66 def named(name) @photos.find { |a| a.name == name } end |
#reload! ⇒ Stellar::Gradebook::StudentList
Reloads the contents of this student list.
81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/stellar/members.rb', line 81 def reload! photo_page = @client.get_nokogiri @url @photos = photo_page.css('#content .cols > div').map { |div| begin Stellar::Members::Photo.new div, @course rescue ArgumentError nil end }.reject(&:nil?) self end |
#with_email(email) ⇒ Stellar::Members::Photo
A photo in the course’s Membership module.
74 75 76 |
# File 'lib/stellar/members.rb', line 74 def with_email(email) @photos.find { |a| a.email == email } end |