class Stellar::Members::PhotoList

Collection of member photos in a course's Membership module.

Attributes

client[R]

Generic Stellar client used to make requests.

course[R]

Client scoped to the Membership module supplying this list of photos.

Public Class Methods

new(members) click to toggle source

Creates a list of member photos for a class.

@param [Stellar::Members] members client scoped to a course's membership

# File lib/stellar/members.rb, line 48
def initialize(members)
  @course = members.course
  @client = members.client
  
  @url = members.navigation['Member Photos']
  reload!
end

Public Instance Methods

all() click to toggle source

All member photos listed in this course's Membership module. @return [Array<Stellar::Members::Photo>] photos of students in this course

# File lib/stellar/members.rb, line 58
def all
  @photos
end
named(name) click to toggle source

A photo in the course's Membership module. @param [String] name the name of the desired member @return [Stellar::Members::Photo] a photo for a member with the given name,

or nil if no such member exists
# File lib/stellar/members.rb, line 66
def named(name)
  @photos.find { |a| a.name == name }
end
reload!() click to toggle source

Reloads the contents of this student list.

@return [Stellar::Gradebook::StudentList] self, for easy call chaining

# 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) click to toggle source

A photo in the course's Membership module. @param [String] email the e-mail of the desired member @return [Stellar::Members::Photo] a photo for a member with the given name,

or nil if no such member exists
# File lib/stellar/members.rb, line 74
def with_email(email)
  @photos.find { |a| a.email == email }
end