Class: LearnSprout::Section

Inherits:
Object
  • Object
show all
Defined in:
lib/learnsprout/section.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ Section

Returns a new instance of Section.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/learnsprout/section.rb', line 13

def initialize(attrs={})
    @client = attrs["client"]
    @org_id = attrs["org_id"]
    @section_id = attrs["id"]
    @number = attrs["number"]
    @room = attrs["room"]
    @term_id = attrs["term"] && attrs["term"]["id"]
    @teacher_id = attrs["teacher"] && attrs["teacher"]["id"]
    @school_id = attrs["school"] && attrs["school"]["id"]
    @course_id = attrs["course"] && attrs["course"]["id"]
    @time_updated = attrs["time_updated"]
    @student_ids = []
    if attrs["students"]
        attrs["students"].each do |student|
            @student_ids.push student["id"]
        end
    end
end

Instance Attribute Details

#course_idObject

Returns the value of attribute course_id.



4
5
6
# File 'lib/learnsprout/section.rb', line 4

def course_id
  @course_id
end

#numberObject

Returns the value of attribute number.



4
5
6
# File 'lib/learnsprout/section.rb', line 4

def number
  @number
end

#roomObject

Returns the value of attribute room.



4
5
6
# File 'lib/learnsprout/section.rb', line 4

def room
  @room
end

#school_idObject

Returns the value of attribute school_id.



4
5
6
# File 'lib/learnsprout/section.rb', line 4

def school_id
  @school_id
end

#section_idObject

Returns the value of attribute section_id.



4
5
6
# File 'lib/learnsprout/section.rb', line 4

def section_id
  @section_id
end

#teacher_idObject

Returns the value of attribute teacher_id.



4
5
6
# File 'lib/learnsprout/section.rb', line 4

def teacher_id
  @teacher_id
end

#term_idObject

Returns the value of attribute term_id.



4
5
6
# File 'lib/learnsprout/section.rb', line 4

def term_id
  @term_id
end

#time_updatedObject

Returns the value of attribute time_updated.



4
5
6
# File 'lib/learnsprout/section.rb', line 4

def time_updated
  @time_updated
end

Instance Method Details

#courseObject



44
45
46
# File 'lib/learnsprout/section.rb', line 44

def course
    @course_id && @client.course(@org_id, @course_id)
end

#schoolObject



40
41
42
# File 'lib/learnsprout/section.rb', line 40

def school
    @school_id && @client.school(@org_id, @school_id)
end

#studentsObject



48
49
50
51
52
53
54
55
56
# File 'lib/learnsprout/section.rb', line 48

def students
  temp_students = []
  if @student_ids.count > 0
     @student_ids.each do |student_id|
       temp_students.push @client.student(@org_id, student_id)
     end
  end
  return temp_students
end

#teacherObject



36
37
38
# File 'lib/learnsprout/section.rb', line 36

def teacher
    @teacher_id && @client.teacher(@org_id, @teacher_id)
end

#termObject



32
33
34
# File 'lib/learnsprout/section.rb', line 32

def term
    @term_id && @client.term(@org_id, @term_id)
end