Class: CanvasAssignment
- Inherits:
-
CanvasObject
- Object
- Forgery
- CanvasObject
- CanvasAssignment
- Defined in:
- lib/models/canvas_assignment.rb
Instance Attribute Summary collapse
-
#assignment_group ⇒ Object
readonly
Returns the value of attribute assignment_group.
-
#course_uid ⇒ Object
readonly
Returns the value of attribute course_uid.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#due_at ⇒ Object
Returns the value of attribute due_at.
-
#host_info ⇒ Object
Returns the value of attribute host_info.
-
#lock_at ⇒ Object
Returns the value of attribute lock_at.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ CanvasAssignment
constructor
A new instance of CanvasAssignment.
- #to_csv ⇒ Object
- #to_s ⇒ Object
Methods inherited from CanvasObject
Constructor Details
#initialize(opts = {}) ⇒ CanvasAssignment
Returns a new instance of CanvasAssignment.
13 14 15 16 17 18 19 20 |
# File 'lib/models/canvas_assignment.rb', line 13 def initialize(opts = {}) @name = opts[:name] if opts[:name] @description = opts[:description] if opts[:description] @due_at = opts[:due_at] if opts[:due_at] @lock_at = opts[:lock_at] if opts[:lock_at] @course_uid = opts[:course_uid] if opts[:course_uid] @assignment_group = opts[:assignment_group] if opts[:assignment_group] end |
Instance Attribute Details
#assignment_group ⇒ Object (readonly)
Returns the value of attribute assignment_group.
2 3 4 |
# File 'lib/models/canvas_assignment.rb', line 2 def assignment_group @assignment_group end |
#course_uid ⇒ Object (readonly)
Returns the value of attribute course_uid.
2 3 4 |
# File 'lib/models/canvas_assignment.rb', line 2 def course_uid @course_uid end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
2 3 4 |
# File 'lib/models/canvas_assignment.rb', line 2 def description @description end |
#due_at ⇒ Object
Returns the value of attribute due_at.
3 4 5 |
# File 'lib/models/canvas_assignment.rb', line 3 def due_at @due_at end |
#host_info ⇒ Object
Returns the value of attribute host_info.
3 4 5 |
# File 'lib/models/canvas_assignment.rb', line 3 def host_info @host_info end |
#lock_at ⇒ Object
Returns the value of attribute lock_at.
3 4 5 |
# File 'lib/models/canvas_assignment.rb', line 3 def lock_at @lock_at end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
2 3 4 |
# File 'lib/models/canvas_assignment.rb', line 2 def name @name end |
Class Method Details
.gen_file(opts = {}) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/models/canvas_assignment.rb', line 36 def self.gen_file(opts = {}) course, group = 1 opts[:rows] ? rows = opts[:rows] : rows = 0 course = opts[:course] if opts[:course] group = opts[:group] if opts[:group] assignments = [] if(opts[:rows]) rows.times do |x| assignments.push(CanvasAssignment.random(course, group)) end end header = %w[name description due_at lock_at course_id assignment_group] CSV.open('./assignments.csv', 'wb', write_headers: true, headers: header) do |csv| assignments.each do |acc| csv << acc.to_csv end end return assignments end |
.random(course = 1, group = 1) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/models/canvas_assignment.rb', line 22 def self.random (course = 1, group = 1) d = Forgery('date').date CanvasAssignment.new( { name: "What #{Forgery('name').job_title} #{Forgery('name').full_name} said about #{Forgery('name').industry}", description: "#{Forgery('lorem_ipsum').paragraphs}", due_at: d, lock_at: d+10.days, course_uid: course, assignment_group: group } ) end |
Instance Method Details
#to_csv ⇒ Object
9 10 11 |
# File 'lib/models/canvas_assignment.rb', line 9 def to_csv row = [name, description, due_at, lock_at, course_uid, assignment_group] end |
#to_s ⇒ Object
5 6 7 |
# File 'lib/models/canvas_assignment.rb', line 5 def to_s string = "#{name}, #{description}, #{due_at}, #{lock_at}, #{course_uid}, #{assignment_group}" end |