class Stellar::HomeworkList

Homework listing functionality.

Public Class Methods

new(course) click to toggle source

Creates a Stellar client scoped to a course's Homework module.

@param [Stellar::Course] the course whose homework is desired

# File lib/stellar/homework.rb, line 9
def initialize(course)
  @course = course
  @client = course.client
  @url = course.navigation['Homework']
  
  page = @client.get_nokogiri @url
  @assignments = page.css('#content a[href*="assignment"]').map { |link|
    name = link.inner_text
    url = URI.join page.url, link['href']
    begin
      Stellar::Homework.new url, name, course
    rescue ArgumentError
      nil
    end
  }.reject(&:nil?)
end

Public Instance Methods

all() click to toggle source

All assignments in this course's homework module. @return [Array<Stellar::Homework>] list of assignments posted by this course

# File lib/stellar/homework.rb, line 28
def all
  @assignments
end
named(name) click to toggle source

An assignment in the course's homework module. @param [String] name the name of the desired assignment @return [Stellar::Homework] an assignment with the given name, or nil if no

such assignment exists
# File lib/stellar/homework.rb, line 36
def named(name)
  @assignments.find { |a| a.name == name }
end