Class: Stellar::Homework::Submission::Comment
- Inherits:
-
Object
- Object
- Stellar::Homework::Submission::Comment
- Defined in:
- lib/stellar/homework.rb
Overview
A comment on a Stellar submission.
Instance Attribute Summary collapse
-
#attachment_url ⇒ Object
readonly
URL to the file attached to the comment.
-
#author ⇒ Object
readonly
Person who posted the comment.
-
#client ⇒ Object
readonly
Generic Stellar client used to make requests.
-
#deleted ⇒ Object
(also: #deleted?)
readonly
True if the comment was deleted.
-
#submission ⇒ Object
readonly
The submission that the comment was posted on.
-
#text ⇒ Object
readonly
Comment text.
Instance Method Summary collapse
-
#attachment_data ⇒ String
The contents of the file attached to this Stellar submission comment.
-
#delete! ⇒ Object
Deletes this comment from Stellar.
-
#initialize(table, submission) ⇒ Comment
constructor
Creates a comment from a <table> in a Stellar submission details page.
Constructor Details
#initialize(table, submission) ⇒ Comment
Creates a comment from a <table> in a Stellar submission details page.
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 |
# File 'lib/stellar/homework.rb', line 201 def initialize(table, submission) @submission = submission @client = @submission.client page_url = table.document.url = table.css('thead tr th.announcedBy').first.inner_text unless content = table.css('tbody tr td.announcement').first raise 'Invalid submission comment table' end if (deleted_text = table.css('tbody tr td.announcement > em').first) && deleted_text.inner_text == 'deleted' @deleted = true @text = nil = nil else @deleted = false unless delete_link = table.css('thead a[href*="delete"]').first raise ArgumentError, 'Invalid submission comment table' end @delete_url = URI.join page_url, delete_link['href'] @text = content.css('p').inner_text = table.css('tbody tr td.announcement > a') if .empty? = nil else = URI.join page_url, .first['href'] end end end |
Instance Attribute Details
#attachment_url ⇒ Object (readonly)
URL to the file attached to the comment. Can be nil.
184 185 186 |
# File 'lib/stellar/homework.rb', line 184 def end |
#author ⇒ Object (readonly)
Person who posted the comment.
180 181 182 |
# File 'lib/stellar/homework.rb', line 180 def end |
#client ⇒ Object (readonly)
Generic Stellar client used to make requests.
193 194 195 |
# File 'lib/stellar/homework.rb', line 193 def client @client end |
#deleted ⇒ Object (readonly) Also known as: deleted?
True if the comment was deleted.
186 187 188 |
# File 'lib/stellar/homework.rb', line 186 def deleted @deleted end |
#submission ⇒ Object (readonly)
The submission that the comment was posted on.
191 192 193 |
# File 'lib/stellar/homework.rb', line 191 def submission @submission end |
#text ⇒ Object (readonly)
Comment text.
182 183 184 |
# File 'lib/stellar/homework.rb', line 182 def text @text end |
Instance Method Details
#attachment_data ⇒ String
The contents of the file attached to this Stellar submission comment.
246 247 248 |
# File 'lib/stellar/homework.rb', line 246 def && @client.get_file() end |
#delete! ⇒ Object
Deletes this comment from Stellar.
234 235 236 237 238 239 240 241 |
# File 'lib/stellar/homework.rb', line 234 def delete! return if @deleted delete_page = @client.get @delete_url delete_form = delete_page.form_with(:action => /delete/i) = delete_form.(:name => /delete/i) delete_form.submit @deleted = true end |