Class: StackConnect
- Inherits:
-
Object
- Object
- StackConnect
- Defined in:
- lib/stackconnect.rb
Constant Summary collapse
- @@VERSION =
"0.0.9"- @@api =
'http://api.stackexchange.com/'- @@site =
'stackoverflow'- @@uri =
URI(@@api)
Instance Attribute Summary collapse
-
#api ⇒ Object
Returns the value of attribute api.
-
#site ⇒ Object
Returns the value of attribute site.
-
#uri ⇒ Object
Returns the value of attribute uri.
Class Method Summary collapse
Instance Method Summary collapse
- #form_query(path, args) ⇒ Object
- #parse ⇒ Object
- #retrieve_day_popular_tags(from_date) ⇒ Object
- #retrieve_hot_questions(from_date, page) ⇒ Object
- #retrieve_most_popular_tags ⇒ Object
- #retrieve_total_questions(from_date) ⇒ Object
Instance Attribute Details
#api ⇒ Object
Returns the value of attribute api.
6 7 8 |
# File 'lib/stackconnect.rb', line 6 def api @api end |
#site ⇒ Object
Returns the value of attribute site.
6 7 8 |
# File 'lib/stackconnect.rb', line 6 def site @site end |
#uri ⇒ Object
Returns the value of attribute uri.
6 7 8 |
# File 'lib/stackconnect.rb', line 6 def uri @uri end |
Class Method Details
.return_version ⇒ Object
51 52 53 |
# File 'lib/stackconnect.rb', line 51 def self.return_version @@VERSION end |
Instance Method Details
#form_query(path, args) ⇒ Object
39 40 41 42 43 44 45 |
# File 'lib/stackconnect.rb', line 39 def form_query (path, args) args.merge!(:site=>'stackoverflow') @@uri.path = path @@uri.query = args.to_query puts @@uri parse end |
#parse ⇒ Object
47 48 49 |
# File 'lib/stackconnect.rb', line 47 def parse JSON.parse(@@uri.open.read) end |
#retrieve_day_popular_tags(from_date) ⇒ Object
24 25 26 27 |
# File 'lib/stackconnect.rb', line 24 def (from_date) args = { :fromdate => from_date, :sort=>'activity', :order=>'desc'} form_query('/2.1/tags', args) end |
#retrieve_hot_questions(from_date, page) ⇒ Object
29 30 31 32 |
# File 'lib/stackconnect.rb', line 29 def retrieve_hot_questions(from_date) args = {:fromdate => from_date, :sort =>'hot', :order=>'desc'} form_query('/2.1/questions', args) end |
#retrieve_most_popular_tags ⇒ Object
19 20 21 22 |
# File 'lib/stackconnect.rb', line 19 def args = {:sort=>'popular', :order=>'desc'} form_query('/2.1/tags', args) end |
#retrieve_total_questions(from_date) ⇒ Object
13 14 15 16 17 |
# File 'lib/stackconnect.rb', line 13 def retrieve_total_questions(from_date) args = {:fromdate=>from_date, :filter => '!--Me6hWI5gUs'} data = form_query('/2.1/questions', args) count = data["total"] end |