rhs-schedule 0.7.0 → 0.8.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 +4 -4
- data/lib/rhs-schedule.rb +19 -10
- data/lib/rhs-schedule/exports.rb +1 -1
- data/lib/rhs-schedule/period.rb +5 -1
- data/lib/rhs-schedule/scheduleday.rb +2 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b306e3e05a4496b0a3e0fa562ece24605badbc2
|
4
|
+
data.tar.gz: e82827d0886d4791bda545235a88d9acf7db8b72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a4a85f0ddf8932ba2cb349cc83fd58dcd0b31a68e2c989cd384d8651342aef38e47dd6f256bd82632efa19ffddd22964d71c4837ea40fd1480ba0bed1f039949
|
7
|
+
data.tar.gz: cd46ede9986f950067f7b7e3fce5c5b217081d93925d8cf0958cd0735421042f5fdabafdbf2470cf50f6ecddb95d8f9afa9a4a22d4ba9a7614e146a579e30fcf
|
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.
|
9
|
+
VERSION = '0.8.0'.freeze
|
10
10
|
|
11
11
|
# e.g. 05/25/16
|
12
12
|
DATE_FORMAT = '%m/%d/%y'.freeze
|
@@ -67,14 +67,26 @@ class ScheduleSystem
|
|
67
67
|
@class_days[@schedule_days[Date.parse(Time.now.to_s)]]
|
68
68
|
end
|
69
69
|
|
70
|
-
#
|
70
|
+
# Gets the current period object of the currently ongoing class (if today is a school day).
|
71
71
|
#
|
72
|
-
# @
|
73
|
-
def
|
74
|
-
|
75
|
-
|
76
|
-
|
72
|
+
# @return [Period, nil] the Period object of the current class or nil if not a school day or school is over
|
73
|
+
def current_period
|
74
|
+
now = DateTime.parse(Time.now.to_s)
|
75
|
+
#now = DateTime.strptime('12:11 PM', TIME_FORMAT)
|
76
|
+
if @schedule_days.key? Date.parse(Time.now.to_s)
|
77
|
+
morning = DateTime.strptime('08:40 AM', TIME_FORMAT)
|
78
|
+
afternoon = DateTime.strptime('02:50 PM', TIME_FORMAT)
|
79
|
+
|
80
|
+
if now >= morning and now <= afternoon
|
81
|
+
# Search for current period
|
82
|
+
today.periods.each do |p|
|
83
|
+
return p if now >= p.start_time and now <= p.end_time
|
84
|
+
end
|
85
|
+
end
|
77
86
|
end
|
87
|
+
|
88
|
+
# Not a school day
|
89
|
+
return nil
|
78
90
|
end
|
79
91
|
|
80
92
|
private
|
@@ -120,8 +132,6 @@ class ScheduleSystem
|
|
120
132
|
ps << vital
|
121
133
|
end
|
122
134
|
end
|
123
|
-
|
124
|
-
puts ps.count { |values| values.any? { |v| v.include? 'Practicum' } }
|
125
135
|
end
|
126
136
|
|
127
137
|
puts "Found #{ps.length} periods for #{sds.length} class days"
|
@@ -145,7 +155,6 @@ class ScheduleSystem
|
|
145
155
|
end
|
146
156
|
|
147
157
|
def create_class_day sd, lines
|
148
|
-
|
149
158
|
periods = []
|
150
159
|
lines.each do |values|
|
151
160
|
# [date, start time, end time, class name, location]
|
data/lib/rhs-schedule/exports.rb
CHANGED
data/lib/rhs-schedule/period.rb
CHANGED
@@ -27,7 +27,11 @@ class Period
|
|
27
27
|
|
28
28
|
# Returns a short summary of the period including subject, location, and duration with times
|
29
29
|
def to_s
|
30
|
-
"#{@course_title} in #{@location} for #{duration} minutes (#{start_time} to #{end_time})"
|
30
|
+
"#{@course_title} in #{@location} for #{duration} minutes (#{start_time.strftime(TIME_FORMAT)} to #{end_time.strftime(TIME_FORMAT)})"
|
31
|
+
end
|
32
|
+
|
33
|
+
def long_location
|
34
|
+
return "Room #{@location}" if Float(@location) rescue @location
|
31
35
|
end
|
32
36
|
|
33
37
|
# Returns the duration of the period in minutes of the period
|
@@ -4,6 +4,7 @@ class ScheduleDay
|
|
4
4
|
attr_reader :schedule_day
|
5
5
|
|
6
6
|
attr_writer :periods
|
7
|
+
# Gets all of the periods in this schedule day.
|
7
8
|
attr_reader :periods
|
8
9
|
|
9
10
|
def initialize(sd, periods)
|
@@ -15,7 +16,7 @@ class ScheduleDay
|
|
15
16
|
def to_s
|
16
17
|
to_return = ["#{@schedule_day}-Day: #{@periods.length} periods"]
|
17
18
|
@periods.each do |p|
|
18
|
-
to_return << " -#{p.to_s}
|
19
|
+
to_return << " -#{p.to_s}"
|
19
20
|
end
|
20
21
|
to_return << "\n"
|
21
22
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rhs-schedule
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Frank Matranga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A RubyGem that parses Regis High School's Intranet schedule download.
|
14
14
|
email: thefrankmatranga@gmail.com
|