lib/models/section.rb in bobross-0.1.6 vs lib/models/section.rb in bobross-0.1.7

- old
+ new

@@ -1,23 +1,25 @@ class Section < Forgery attr_reader :name, :sis_id, :course_id, :course_sis_id, :start_at, :end_at attr_writer :course, :course_sis_id - def initialize(name, sis_id, course, start_at, end_at) - @name = name - @sis_id = sis_id - @course_id = course - @start_at = start_at - @end_at = end_at + def initialize(opts = {}) + @name = opts[:name] if opts[:name] + @sis_id = opts[:sis_id] if opts[:sis_id] + @course_id = opts[:course] if opts[:course] + @start_at = opts[:start_at] if opts[:start_at] + @end_at = opts[:end_at] if opts[:end_at] end def self.random(course=1) d = Forgery('date').date Section.new( - "#{Forgery('address').country} #{Forgery('basic').color}", - (21000+rand(1000000)), - course, - d, - d+90.days + { + name: "#{Forgery('address').country} #{Forgery('basic').color}", + sis_id: (21000+rand(1000000)), + course: course, + start_at: d, + end_at: d+90.days + } ) end end