Module: ScheduleScraper::Event
- Included in:
- ScheduleScraper::EZLeagues::Event, Pointstreak::Event
- Defined in:
- lib/schedule-scraper/event.rb
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
- #all_day? ⇒ Boolean
- #date_time_string(dt) ⇒ Object
- #description ⇒ Object
- #end_date ⇒ Object
- #end_date_time ⇒ Object
- #private? ⇒ Boolean
- #start_date ⇒ Object
-
#start_date_time ⇒ Object
def end_time will default to one hour? end.
- #start_time ⇒ Object
- #title ⇒ Object
- #to_csv ⇒ Object
- #to_gcal ⇒ Object
- #to_h ⇒ Object
- #to_ical(cal) ⇒ Object
Class Method Details
.included(base) ⇒ Object
11 12 13 |
# File 'lib/schedule-scraper/event.rb', line 11 def self.included(base) base.extend ClassMethods end |
Instance Method Details
#all_day? ⇒ Boolean
19 20 21 |
# File 'lib/schedule-scraper/event.rb', line 19 def all_day? false end |
#date_time_string(dt) ⇒ Object
58 59 60 |
# File 'lib/schedule-scraper/event.rb', line 58 def date_time_string(dt) dt.strftime "%Y%m%dT%H%M%S" end |
#description ⇒ Object
23 24 25 |
# File 'lib/schedule-scraper/event.rb', line 23 def description title end |
#end_date ⇒ Object
31 32 33 |
# File 'lib/schedule-scraper/event.rb', line 31 def end_date start_date end |
#end_date_time ⇒ Object
53 54 55 56 |
# File 'lib/schedule-scraper/event.rb', line 53 def end_date_time # default to 1 hr start_date_time.to_time + 3600 end |
#private? ⇒ Boolean
62 63 64 |
# File 'lib/schedule-scraper/event.rb', line 62 def private? true end |
#start_date ⇒ Object
27 28 29 |
# File 'lib/schedule-scraper/event.rb', line 27 def start_date Date.parse(date).strftime(date_format) end |
#start_date_time ⇒ Object
def end_time
will default to one hour?
end
49 50 51 |
# File 'lib/schedule-scraper/event.rb', line 49 def start_date_time DateTime.strptime "#{start_date} #{start_time}", '%m/%d/%y %H:%M %P' end |
#start_time ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/schedule-scraper/event.rb', line 35 def start_time begin Time.parse(time) time rescue # looks like an invalid time "12:00 PM" end end |
#title ⇒ Object
15 16 17 |
# File 'lib/schedule-scraper/event.rb', line 15 def title "#{home_team} vs. #{away_team}" end |
#to_csv ⇒ Object
66 67 68 69 70 |
# File 'lib/schedule-scraper/event.rb', line 66 def to_csv self.class.export_fields.collect do |field| self.send(field) end end |
#to_gcal ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/schedule-scraper/event.rb', line 72 def to_gcal [ title, start_date, start_time, end_date, "", all_day?, description, "", private? ] end |
#to_h ⇒ Object
95 96 97 98 99 100 101 102 103 104 |
# File 'lib/schedule-scraper/event.rb', line 95 def to_h { :title => title, :start_date => start_date, :start_time => start_time, :end_date => end_date, :all_day => all_day?, :description => description } end |
#to_ical(cal) ⇒ Object
86 87 88 89 90 91 92 93 |
# File 'lib/schedule-scraper/event.rb', line 86 def to_ical(cal) cal.event do |event| event.summary description event.dtstart date_time_string(start_date_time) event.dtend date_time_string(end_date_time) event.location "" end end |