class Stellar::Homework
One assignment in the homework tab.
Attributes
client[R]
Generic Stellar
client used to make requests.
course[R]
The course that this assignment is for.
name[R]
Assignment name.
Public Class Methods
new(page_url, name, course)
click to toggle source
Creates a Stellar
client scoped to an assignment.
@param [URI, String] page_url URL to the assignment's main Stellar
page @param [String] assignment name, e.g. “name” @param [Course] the course that issued the assignment
# File lib/stellar/homework.rb, line 57 def initialize(page_url, name, course) @name = name @url = page_url @course = course @client = course.client page = @client.get_nokogiri @url unless page.css('#content p b').any? { |dom| dom.inner_text.strip == name } raise ArgumentError, 'Invalid homework page URL' end end
Public Instance Methods
submissions()
click to toggle source
List of submissions associated with this problem set.
# File lib/stellar/homework.rb, line 70 def submissions page = @client.get_nokogiri @url @submissions ||= page.css('.gradeTable tbody tr').map { |tr| begin Stellar::Homework::Submission.new tr, self rescue ArgumentError nil end }.reject(&:nil?) end