Class: Base
- Inherits:
-
Object
show all
- Includes:
- HTTParty
- Defined in:
- lib/event_finda_ruby/base.rb
Constant Summary
collapse
- BASE_URL =
"http://api.eventfinda.co.nz/v2/".freeze
- RESOURCE_SLUG =
"base"
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize ⇒ Base
Returns a new instance of Base.
12
13
14
15
|
# File 'lib/event_finda_ruby/base.rb', line 12
def initialize
@api_extension = "json"
@filters = { "rows" => "20" }
end
|
Instance Attribute Details
#api_extension ⇒ Object
Returns the value of attribute api_extension.
9
10
11
|
# File 'lib/event_finda_ruby/base.rb', line 9
def api_extension
@api_extension
end
|
#filters ⇒ Object
Returns the value of attribute filters.
10
11
12
|
# File 'lib/event_finda_ruby/base.rb', line 10
def filters
@filters
end
|
Instance Method Details
#by_keywords_and(keywords) ⇒ Object
17
18
19
20
21
|
# File 'lib/event_finda_ruby/base.rb', line 17
def by_keywords_and(keywords)
apply_filter "q", set_keywords_and(keywords)
self
end
|
#by_keywords_or(keywords) ⇒ Object
23
24
25
26
27
|
# File 'lib/event_finda_ruby/base.rb', line 23
def by_keywords_or(keywords)
apply_filter "q", set_keywords_or(keywords)
self
end
|
#by_query(query) ⇒ Object
29
30
31
32
33
|
# File 'lib/event_finda_ruby/base.rb', line 29
def by_query(query)
apply_filter "q", query
self
end
|
#by_rows(rows) ⇒ Object
35
36
37
38
39
|
# File 'lib/event_finda_ruby/base.rb', line 35
def by_rows(rows)
apply_filter "rows", rows
self
end
|
#results ⇒ Object
41
42
43
|
# File 'lib/event_finda_ruby/base.rb', line 41
def results
@results = response["#{self.class::RESOURCE_SLUG}"]
end
|
#url ⇒ Object
45
46
47
|
# File 'lib/event_finda_ruby/base.rb', line 45
def url
"#{BASE_URL}#{self.class::RESOURCE_SLUG}.#{api_extension}?#{get_filters}"
end
|
#with_extension(extension) ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/event_finda_ruby/base.rb', line 49
def with_extension(extension)
if ["json", "xml"].include? extension
@api_extension = extension
end
self
end
|