Class: Stellar::Members::PhotoList

Inherits:
Object
  • Object
show all
Defined in:
lib/stellar/members.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(members) ⇒ PhotoList

Creates a list of member photos for a class.

Parameters:



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.navigation['Member Photos']
  reload!
end

Instance Attribute Details

#clientObject (readonly)

Generic Stellar client used to make requests.



43
44
45
# File 'lib/stellar/members.rb', line 43

def client
  @client
end

#courseObject (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

#allArray<Stellar::Members::Photo>

All member photos listed in this course’s Membership module.

Returns:



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.

Parameters:

  • name (String)

    the name of the desired member

Returns:



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.

Returns:



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.

Parameters:

  • email (String)

    the e-mail of the desired member

Returns:



74
75
76
# File 'lib/stellar/members.rb', line 74

def with_email(email)
  @photos.find { |a| a.email == email }
end