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
- .file_attribute_name_to_data_attribute_name(file_attribute) ⇒ Object
- .from_buffer(io, profile: Meibo.current_profile) ⇒ Object
- .from_file(file_path, profile: Meibo.current_profile) ⇒ Object
- .open(io_or_path) ⇒ 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, create: true) ⇒ 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.
102 103 104 105 106 107 108 109 110 111 112 113 114 115 |
# File 'lib/meibo/roster.rb', line 102 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(:file_academic_sessions).new(academic_sessions, roster: self) @classes = profile.data_set_for(:file_classes).new(classes, roster: self) @courses = profile.data_set_for(:file_courses).new(courses, roster: self) @demographics = profile.data_set_for(:file_demographics).new(demographics, roster: self) @enrollments = profile.data_set_for(:file_enrollments).new(enrollments, roster: self) @organizations = profile.data_set_for(:file_orgs).new(organizations, roster: self) @roles = profile.data_set_for(:file_roles).new(roles, roster: self) @user_profiles = profile.data_set_for(:file_user_profiles).new(user_profiles, roster: self) @users = profile.data_set_for(:file_users).new(users, roster: self) end |
Instance Attribute Details
#academic_sessions ⇒ Object (readonly)
Returns the value of attribute academic_sessions.
99 100 101 |
# File 'lib/meibo/roster.rb', line 99 def academic_sessions @academic_sessions end |
#classes ⇒ Object (readonly)
Returns the value of attribute classes.
99 100 101 |
# File 'lib/meibo/roster.rb', line 99 def classes @classes end |
#courses ⇒ Object (readonly)
Returns the value of attribute courses.
99 100 101 |
# File 'lib/meibo/roster.rb', line 99 def courses @courses end |
#demographics ⇒ Object (readonly)
Returns the value of attribute demographics.
99 100 101 |
# File 'lib/meibo/roster.rb', line 99 def demographics @demographics end |
#enrollments ⇒ Object (readonly)
Returns the value of attribute enrollments.
99 100 101 |
# File 'lib/meibo/roster.rb', line 99 def enrollments @enrollments end |
#manifest_properties ⇒ Object (readonly)
Returns the value of attribute manifest_properties.
99 100 101 |
# File 'lib/meibo/roster.rb', line 99 def manifest_properties @manifest_properties end |
#organizations ⇒ Object (readonly)
Returns the value of attribute organizations.
99 100 101 |
# File 'lib/meibo/roster.rb', line 99 def organizations @organizations end |
#profile ⇒ Object (readonly)
Returns the value of attribute profile.
99 100 101 |
# File 'lib/meibo/roster.rb', line 99 def profile @profile end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
99 100 101 |
# File 'lib/meibo/roster.rb', line 99 def roles @roles end |
#user_profiles ⇒ Object (readonly)
Returns the value of attribute user_profiles.
99 100 101 |
# File 'lib/meibo/roster.rb', line 99 def user_profiles @user_profiles end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
99 100 101 |
# File 'lib/meibo/roster.rb', line 99 def users @users end |
Class Method Details
.file_attribute_name_to_data_attribute_name(file_attribute) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/meibo/roster.rb', line 9 def file_attribute_name_to_data_attribute_name(file_attribute) { file_academic_sessions: :academic_sessions, file_classes: :classes, file_courses: :courses, file_demographics: :demographics, file_enrollments: :enrollments, file_orgs: :organizations, file_roles: :roles, file_user_profiles: :user_profiles, file_users: :users }[file_attribute] end |
.from_buffer(io, profile: Meibo.current_profile) ⇒ Object
29 30 31 32 33 |
# File 'lib/meibo/roster.rb', line 29 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
23 24 25 26 27 |
# File 'lib/meibo/roster.rb', line 23 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) ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/meibo/roster.rb', line 35 def open(io_or_path, **) m = io_or_path.is_a?(IO) ? :from_buffer : :from_file roster = public_send(m, io_or_path, **) return roster unless block_given? Meibo.with_roster(roster) { yield roster } end |
Instance Method Details
#builder ⇒ Object
117 118 119 |
# File 'lib/meibo/roster.rb', line 117 def builder Builder.new(roster: self, profile: profile) end |
#check_semantically_consistent ⇒ Object
121 122 123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/meibo/roster.rb', line 121 def check_semantically_consistent [ academic_sessions, classes, courses, demographics, enrollments, organizations, roles, user_profiles, users ].each(&:check_semantically_consistent) end |
#write_to_buffer(io, create: true) ⇒ Object
135 136 137 138 139 |
# File 'lib/meibo/roster.rb', line 135 def write_to_buffer(io, create: true) Zip::File.open_buffer(io, create:) do |zipfile| write(zipfile) end end |
#write_to_file(path) ⇒ Object
141 142 143 144 145 |
# File 'lib/meibo/roster.rb', line 141 def write_to_file(path) Zip::File.open(path, Zip::File::CREATE) do |zipfile| write(zipfile) end end |