class Eventify::Provider::Base

Constants

MissingAttributeError

Attributes

date[R]
id[R]
title[R]

Public Class Methods

fetch() click to toggle source
# File lib/eventify/provider/base.rb, line 7
def fetch
  raise NotImplementedError
end
new(event) click to toggle source
# File lib/eventify/provider/base.rb, line 14
def initialize(event)
  @id = event[:id] or raise MissingAttributeError.new("id is missing")
  @title = event[:title] or raise MissingAttributeError.new("title is missing")
  @link = event[:link] or raise MissingAttributeError.new("link is missing")
  @date = event[:date]
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/eventify/provider/base.rb, line 48
def <=>(other)
  title <=> other.title
end
==(other) click to toggle source
# File lib/eventify/provider/base.rb, line 34
def ==(other)
  id == other.id &&
    provider == other.provider &&
    title == other.title &&
    link == other.link &&
    date.to_i == other.date.to_i
end
Also aliased as: eql?
eql?(other)
Alias for: ==
exists?() click to toggle source
# File lib/eventify/provider/base.rb, line 30
def exists?
  Database.exists? self
end
hash() click to toggle source
# File lib/eventify/provider/base.rb, line 44
def hash
  "#{id}-#{provider}-#{title}-#{link}-#{date.to_i}".hash
end
provider() click to toggle source
# File lib/eventify/provider/base.rb, line 21
def provider
  @provider ||= self.class.name
end
save() click to toggle source
# File lib/eventify/provider/base.rb, line 25
def save
  Database.save self 
  self
end