Class: Google

Inherits:
Object
  • Object
show all
Defined in:
lib/musicscrape.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#date=(value) ⇒ Object (writeonly)

Sets the attribute date

Parameters:

  • value

    the value to set the attribute date to.



92
93
94
# File 'lib/musicscrape.rb', line 92

def date=(value)
  @date = value
end

#details=(value) ⇒ Object (writeonly)

Sets the attribute details

Parameters:

  • value

    the value to set the attribute details to.



93
94
95
# File 'lib/musicscrape.rb', line 93

def details=(value)
  @details = value
end

#password=(value) ⇒ Object (writeonly)

the plan is to make it add the events to your google calendar. Not yet Functional.



88
89
90
# File 'lib/musicscrape.rb', line 88

def password=(value)
  @password = value
end

#title=(value) ⇒ Object (writeonly)

Sets the attribute title

Parameters:

  • value

    the value to set the attribute title to.



90
91
92
# File 'lib/musicscrape.rb', line 90

def title=(value)
  @title = value
end

#user=(value) ⇒ Object (writeonly)

Sets the attribute user

Parameters:

  • value

    the value to set the attribute user to.



89
90
91
# File 'lib/musicscrape.rb', line 89

def user=(value)
  @user = value
end

#venue=(value) ⇒ Object (writeonly)

Sets the attribute venue

Parameters:

  • value

    the value to set the attribute venue to.



91
92
93
# File 'lib/musicscrape.rb', line 91

def venue=(value)
  @venue = value
end

Instance Method Details

#convert(event_date) ⇒ Object



98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
# 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) ⇒ Object



123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/musicscrape.rb', line 123

def create_event(title, venue, date, details)
  @date = convert(date)
  serv = GCal4Ruby::Service.new
  serv.authenticate "[email protected]", "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