rhs-schedule 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 45d9d22b1f06bf65d5f7f19cbb0f865696c07088
4
- data.tar.gz: 83e50e970284e01b6812b0b35e0600fa0a0dcefa
3
+ metadata.gz: d78ca9524a73504524f2f92521fa48d1e90db7f9
4
+ data.tar.gz: 373349b5453a766fedff74cf46cfd97390c26231
5
5
  SHA512:
6
- metadata.gz: e4935fae5a8bb3fa729b7b5e49be49b18958aef622af9192a401ed0b055e10b44d6bcf5ceafde6e4eb97718a76b60a796cdfd96db41021c9b3132fc371337578
7
- data.tar.gz: 26dc3d276c130f0a6b552ce4233389478a66d1324c1edeb09a630090071acb2b6b96fe7e150f770c71a04e90f01cc2f6e7d8389248f3b2f3133c318b797339c0
6
+ metadata.gz: 5a0dcb14e0d91cff691032cc93b62600b26ced05271d9669db658a570949694fd6f1478c6349940bf9a195850adf6e8f1c1fdfd0bd2955ad22999ede2e8e511c
7
+ data.tar.gz: c927c5441c7e426bf98061aed9f9f276efc7a94b7ce7c8d747f498560e414e25d07cff162162237a983e1fa66239f8955d821515764fec7398ff5b4d5c297fae
data/lib/rhs-schedule.rb CHANGED
@@ -6,7 +6,7 @@ require_relative 'rhs-schedule/period'
6
6
  require_relative 'rhs-schedule/exports'
7
7
  require_relative 'rhs-schedule/errors'
8
8
 
9
- VERSION = '0.3.0'.freeze
9
+ VERSION = '0.5.0'.freeze
10
10
 
11
11
  # 05/25/16 08:50 AM
12
12
  DATE_FORMAT = '%m/%d/%y'.freeze
@@ -18,6 +18,7 @@ class ScheduleSystem
18
18
  include Exports
19
19
 
20
20
  attr_reader :schedule_days
21
+ attr_reader :class_days
21
22
 
22
23
  # Creates a new ScheduleSystem by parsing the schedule text file passed to it.
23
24
  # If it cannot read the file the program aborts.
@@ -28,7 +29,7 @@ class ScheduleSystem
28
29
  abort "Cannot find schedule text file at '#{path}'. Please download it from http://intranet.regis.org/downloads/outlook_calendar_import/outlook_schedule_download.cfm." unless File.file? path
29
30
 
30
31
  @path = path
31
- @classdays = []
32
+ @class_days = {}
32
33
  @schedule_days = {}
33
34
  parse
34
35
  super(self) # Initialize the exports with the parsed schedule
@@ -50,8 +51,7 @@ class ScheduleSystem
50
51
  # Displays formatted info on the current day, including it's schedule day and classes in order.
51
52
  def today
52
53
  #false_date = Date.strptime('05/20/16', DATE_FORMAT)
53
- @classdays.find { |cd| cd.schedule_day == @schedule_days[Date.parse(Time.now.to_s)]}
54
- #@classdays.find { |cd| cd.schedule_day == @schedule_days[false_date] }
54
+ @class_days[@schedule_days[Date.parse(Time.now.to_s)]]
55
55
  end
56
56
 
57
57
  # Outputs a JSON object of all class days and their schedule days into the given file.
@@ -94,7 +94,6 @@ class ScheduleSystem
94
94
 
95
95
  lines.each do |line|
96
96
  next if line.include? 'Start Date' or line.strip.empty?
97
-
98
97
  # Split the line and remove all the unnecessary values
99
98
  values = line.split("\t")
100
99
 
@@ -109,6 +108,8 @@ class ScheduleSystem
109
108
  ps << vital
110
109
  end
111
110
  end
111
+
112
+ puts ps.count { |values| values.any? { |v| v.include? 'Practicum' } }
112
113
  end
113
114
 
114
115
  puts "Found #{ps.length} periods for #{sds.length} class days"
@@ -117,8 +118,8 @@ class ScheduleSystem
117
118
  handled = [] # Holds what schedules have been made
118
119
  @schedule_days.each do |date, sd|
119
120
  next if handled.include? sd
121
+ lines = ps.find_all { |values| values[0].gsub(/\n/, "") == date.strftime(DATE_FORMAT) }
120
122
 
121
- lines = ps.find_all { |values| values[0] == date.strftime(DATE_FORMAT) }
122
123
  next if lines.empty?
123
124
  create_class_day sd, lines
124
125
  handled << sd
@@ -132,6 +133,7 @@ class ScheduleSystem
132
133
  end
133
134
 
134
135
  def create_class_day sd, lines
136
+
135
137
  periods = []
136
138
  lines.each do |values|
137
139
  # [date, start time, end time, class name, location]
@@ -145,7 +147,7 @@ class ScheduleSystem
145
147
 
146
148
  day = ScheduleDay.new(sd, periods)
147
149
  fill_periods day
148
- @classdays << day
150
+ @class_days[sd] = day
149
151
  end
150
152
 
151
153
  # Take a just created periods list and fill in the holes (lunch and frees)
@@ -172,6 +174,4 @@ class ScheduleSystem
172
174
  filled << Period.new('Afternoon Advisement', DateTime.strptime('2:50 PM', TIME_FORMAT), DateTime.strptime('3:00 PM', TIME_FORMAT), 'Advisement')
173
175
  day.periods = filled
174
176
  end
175
-
176
-
177
177
  end
@@ -1,6 +1,8 @@
1
1
  class Period
2
2
  attr_reader :start_time
3
3
  attr_reader :end_time
4
+ attr_reader :course_title
5
+ attr_reader :location
4
6
 
5
7
  def initialize(course, start_time, end_time, location)
6
8
  @course_title = course
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rhs-schedule
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank Matranga