class Google
Attributes
date[W]
details[W]
password[W]
the plan is to make it add the events to your google calendar. Not yet Functional.
title[W]
user[W]
venue[W]
Public Instance Methods
convert(event_date)
click to toggle source
# File lib/musicscrape.rb, line 98 def convert(event_date) #convert a stranger date to a google date #find out what day of the week today is #assume that Sun...Sat are the next one #{0=>'Sun', 1=>'Mon', 2=>'Tues', 3=>'Wed', 4=>'Thurs', 5=> 'Fri', 6=>'Sat', day_array=[0,1,2,3,4,5,6] #to make subtracted days of week wrap around day_hash = {:Sun=>0,:Mon=>1,:Tue=>2, :Wed=>3,:Thurs=>4,:Fri=>5,:Sat=>6} month_hash = {:Jan=>1, :Feb=>2, :Mar=>3, :Apr=>4, :May=>5, :Jun=>6, :Jul=>7, :Aug=>8, :Sep=>9,:Oct=>10, :Nov=>11, :Dec=>12 } current_time = Time.now current_day = current_time.wday date_array = event_date.split(" ") if date_array.size == 3 #if it's 3 words assume the format is Day Month Date event_day = day_hash[date_array[0].capitalize.to_sym] event_month = month_hash[date_array[1].capitalize.to_sym] event_date = date_array[2].to_i event_time = Time.local(current_time.year,event_month,event_date) else #it's going to be in the form 'Every Mon' but we will only put it on for this week event_day = day_hash[date_array[1].capitalize.to_sym] #find the number 0 to 6 for event day event_time = current_time + (60*60*24*day_array[event_day - current_day])#get the differential from todays day end event_time end
create_event(title, venue, date, details)
click to toggle source
# File lib/musicscrape.rb, line 123 def create_event(title, venue, date, details) @date = convert(date) serv = GCal4Ruby::Service.new serv.authenticate "fakeemail@gmail.com", "fakepassword" calendar = GCal4Ruby::Calendar.new(serv) event = GCal4Ruby::Event.new(calendar) event.title = @title event.start_time = @date event.end_time = @date + 60*60 #add an hour for the end time event.where = @venue event.send end