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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 172e5a7deee9a6fbcc7a87c64a5af9d14b2fa4f0
4
- data.tar.gz: 0f33998edeed880f68b33d48d91f04f4bd38dc5d
3
+ metadata.gz: 9b306e3e05a4496b0a3e0fa562ece24605badbc2
4
+ data.tar.gz: e82827d0886d4791bda545235a88d9acf7db8b72
5
5
  SHA512:
6
- metadata.gz: 0a0d21f8253a8608904f8fa215296d16360673e45cb7608cd6ad98b4b7c4e517e47a362f6fbf0e605a8f5bbc05c664b22c5f7f24bb95f4c135c4a5c4b0bb6b77
7
- data.tar.gz: 55de0b13178b3b7df12acf93b038af95cb4f3ae8269317c2d36a6be9b07c62830da9e5337f5098650b6246a27933c758e6b6a67add0137e3cc619066910de9ba
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.7.0'.freeze
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
- # Outputs a JSON object of all class days and their schedule days into the given file.
70
+ # Gets the current period object of the currently ongoing class (if today is a school day).
71
71
  #
72
- # @param path [String] the file path
73
- def to_json(path)
74
- puts 'Exporting schedule days to JSON'
75
- File.open(path,'w') do |f|
76
- f.write(JSON.pretty_generate(@schedule.schedule_days))
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]
@@ -2,7 +2,7 @@ module Exports
2
2
  def initialize(schedule)
3
3
  @schedule = schedule
4
4
  end
5
-
5
+
6
6
  # Outputs the current schedule in JSON format to the path specified. (NOT YET IMPLEMENTED)
7
7
  def to_json(path, include_advisements=false, include_frees=false)
8
8
  puts "Not yet implemented."
@@ -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}\n"
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.7.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-10-12 00:00:00.000000000 Z
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