Class: Meibo::Roster
- Inherits:
-
Object
- Object
- Meibo::Roster
- Defined in:
- lib/meibo/roster.rb
Instance Attribute Summary collapse
-
#academic_sessions ⇒ Object
readonly
Returns the value of attribute academic_sessions.
-
#classes ⇒ Object
readonly
Returns the value of attribute classes.
-
#courses ⇒ Object
readonly
Returns the value of attribute courses.
-
#demographics ⇒ Object
readonly
Returns the value of attribute demographics.
-
#enrollments ⇒ Object
readonly
Returns the value of attribute enrollments.
-
#manifest_properties ⇒ Object
readonly
Returns the value of attribute manifest_properties.
-
#organizations ⇒ Object
readonly
Returns the value of attribute organizations.
-
#profile ⇒ Object
readonly
Returns the value of attribute profile.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
-
#user_profiles ⇒ Object
readonly
Returns the value of attribute user_profiles.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
Class Method Summary collapse
- .from_buffer(io, profile: Meibo.current_profile) ⇒ Object
- .from_file(file_path, profile: Meibo.current_profile) ⇒ Object
- .open(io_or_path, **opts) ⇒ Object
Instance Method Summary collapse
- #builder ⇒ Object
- #check_semantically_consistent ⇒ Object
-
#initialize(profile: Meibo.current_profile, manifest_properties: {}, academic_sessions: [], classes: [], courses: [], demographics: [], enrollments: [], organizations: [], roles: [], user_profiles: [], users: []) ⇒ Roster
constructor
A new instance of Roster.
- #write_to_buffer(io) ⇒ Object
- #write_to_file(path) ⇒ Object
Constructor Details
#initialize(profile: Meibo.current_profile, manifest_properties: {}, academic_sessions: [], classes: [], courses: [], demographics: [], enrollments: [], organizations: [], roles: [], user_profiles: [], users: []) ⇒ Roster
Returns a new instance of Roster.
89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/meibo/roster.rb', line 89 def initialize(profile: Meibo.current_profile, manifest_properties: {}, academic_sessions: [], classes: [], courses: [], demographics: [], enrollments: [], organizations: [], roles: [], user_profiles: [], users: []) @profile = profile @manifest_properties = manifest_properties @academic_sessions = profile.data_set_for(:academic_sessions).new(academic_sessions, roster: self) @classes = profile.data_set_for(:classes).new(classes, roster: self) @courses = profile.data_set_for(:courses).new(courses, roster: self) @demographics = profile.data_set_for(:demographics).new(demographics, roster: self) @enrollments = profile.data_set_for(:enrollments).new(enrollments, roster: self) @organizations = profile.data_set_for(:orgs).new(organizations, roster: self) @roles = profile.data_set_for(:roles).new(roles, roster: self) @user_profiles = profile.data_set_for(:user_profiles).new(user_profiles, roster: self) @users = profile.data_set_for(:users).new(users, roster: self) end |
Instance Attribute Details
#academic_sessions ⇒ Object (readonly)
Returns the value of attribute academic_sessions.
86 87 88 |
# File 'lib/meibo/roster.rb', line 86 def academic_sessions @academic_sessions end |
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
86 87 88 |
# File 'lib/meibo/roster.rb', line 86 def classes @classes end |
#courses ⇒ Object (readonly)
Returns the value of attribute courses.
86 87 88 |
# File 'lib/meibo/roster.rb', line 86 def courses @courses end |
#demographics ⇒ Object (readonly)
Returns the value of attribute demographics.
86 87 88 |
# File 'lib/meibo/roster.rb', line 86 def demographics @demographics end |
#enrollments ⇒ Object (readonly)
Returns the value of attribute enrollments.
86 87 88 |
# File 'lib/meibo/roster.rb', line 86 def enrollments @enrollments end |
#manifest_properties ⇒ Object (readonly)
Returns the value of attribute manifest_properties.
86 87 88 |
# File 'lib/meibo/roster.rb', line 86 def manifest_properties @manifest_properties end |
#organizations ⇒ Object (readonly)
Returns the value of attribute organizations.
86 87 88 |
# File 'lib/meibo/roster.rb', line 86 def organizations @organizations end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
86 87 88 |
# File 'lib/meibo/roster.rb', line 86 def profile @profile end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
86 87 88 |
# File 'lib/meibo/roster.rb', line 86 def roles @roles end |
#user_profiles ⇒ Object (readonly)
Returns the value of attribute user_profiles.
86 87 88 |
# File 'lib/meibo/roster.rb', line 86 def user_profiles @user_profiles end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
86 87 88 |
# File 'lib/meibo/roster.rb', line 86 def users @users end |
Class Method Details
.from_buffer(io, profile: Meibo.current_profile) ⇒ Object
15 16 17 18 19 |
# File 'lib/meibo/roster.rb', line 15 def from_buffer(io, profile: Meibo.current_profile) Reader.open_buffer(io, profile: profile) do |reader| return read_data(reader, profile) end end |
.from_file(file_path, profile: Meibo.current_profile) ⇒ Object
9 10 11 12 13 |
# File 'lib/meibo/roster.rb', line 9 def from_file(file_path, profile: Meibo.current_profile) Reader.open(file_path, profile: profile) do |reader| return read_data(reader, profile) end end |
.open(io_or_path, **opts) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/meibo/roster.rb', line 21 def open(io_or_path, **opts) m = io_or_path.is_a?(IO) ? :from_buffer : :from_file roster = public_send(m, io_or_path, **opts) return roster unless block_given? Meibo.with_roster(roster) { yield roster } end |
Instance Method Details
#builder ⇒ Object
104 105 106 |
# File 'lib/meibo/roster.rb', line 104 def builder Builder.new(roster: self, profile: profile) end |
#check_semantically_consistent ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 |
# File 'lib/meibo/roster.rb', line 108 def check_semantically_consistent [ academic_sessions, classes, courses, demographics, enrollments, organizations, roles, user_profiles, users ].each(&:check_semantically_consistent) end |
#write_to_buffer(io) ⇒ Object
122 123 124 125 126 |
# File 'lib/meibo/roster.rb', line 122 def write_to_buffer(io) Zip::File.open_buffer(io) do |zipfile| write(zipfile) end end |
#write_to_file(path) ⇒ Object
128 129 130 131 132 |
# File 'lib/meibo/roster.rb', line 128 def write_to_file(path) Zip::File.open(path, Zip::File::CREATE) do |zipfile| write(zipfile) end end |