Class: Eventify::Provider::Base
- Inherits:
-
Object
- Object
- Eventify::Provider::Base
show all
- Includes:
- Comparable
- Defined in:
- lib/eventify/provider/base.rb
Constant Summary
collapse
- MissingAttributeError =
Class.new(RuntimeError)
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(event) ⇒ Base
Returns a new instance of Base.
14
15
16
17
18
19
|
# 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
|
Instance Attribute Details
#date ⇒ Object
Returns the value of attribute date.
12
13
14
|
# File 'lib/eventify/provider/base.rb', line 12
def date
@date
end
|
#id ⇒ Object
Returns the value of attribute id.
12
13
14
|
# File 'lib/eventify/provider/base.rb', line 12
def id
@id
end
|
#link ⇒ Object
Returns the value of attribute link.
12
13
14
|
# File 'lib/eventify/provider/base.rb', line 12
def link
@link
end
|
#title ⇒ Object
Returns the value of attribute title.
12
13
14
|
# File 'lib/eventify/provider/base.rb', line 12
def title
@title
end
|
Class Method Details
.fetch ⇒ Object
7
8
9
|
# File 'lib/eventify/provider/base.rb', line 7
def fetch
raise NotImplementedError
end
|
Instance Method Details
#<=>(other) ⇒ Object
48
49
50
|
# File 'lib/eventify/provider/base.rb', line 48
def <=>(other)
title <=> other.title
end
|
#==(other) ⇒ Object
Also known as:
eql?
34
35
36
37
38
39
40
|
# 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
|
#exists? ⇒ Boolean
30
31
32
|
# File 'lib/eventify/provider/base.rb', line 30
def exists?
Database.exists? self
end
|
#hash ⇒ Object
44
45
46
|
# File 'lib/eventify/provider/base.rb', line 44
def hash
"#{id}-#{provider}-#{title}-#{link}-#{date.to_i}".hash
end
|
#provider ⇒ Object
21
22
23
|
# File 'lib/eventify/provider/base.rb', line 21
def provider
@provider ||= self.class.name
end
|
#save ⇒ Object
25
26
27
28
|
# File 'lib/eventify/provider/base.rb', line 25
def save
Database.save self
self
end
|