blob: 24404f1ad7704e9c057120c7d2bc02fbf7279d15 (
plain) (
tree)
|
|
require 'time'
module Events
class Event
attr_reader :start_time
attr_reader :duration
attr_reader :title
attr_reader :venue
attr_reader :image_url
attr_reader :info_link
def initialize(attrs)
@start_time = Time.parse(attrs['start_time'])
@duration = attrs['duration'].to_i
@title = attrs['title']
@venue = attrs['venue']
@image_url = attrs['image'] unless attrs['image'].length < 10
@info_link = attrs['info_link']
end
def date
@start_time.to_date
end
def end_time
@start_time + @duration
end
def slug
"#{start_time.to_i}-#{title.downcase.gsub(/[^a-z0-9_-]/, '')}"
end
end
end
|