Class: StackConnect

Inherits:
Object
  • Object
show all
Defined in:
lib/stackconnect.rb

Constant Summary collapse

@@VERSION =
"0.0.7"
@@api =
'http://api.stackexchange.com/'
@@site =
'stackoverflow'
@@uri =
URI(@@api)

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#apiObject

Returns the value of attribute api.



6
7
8
# File 'lib/stackconnect.rb', line 6

def api
  @api
end

#siteObject

Returns the value of attribute site.



6
7
8
# File 'lib/stackconnect.rb', line 6

def site
  @site
end

#uriObject

Returns the value of attribute uri.



6
7
8
# File 'lib/stackconnect.rb', line 6

def uri
  @uri
end

Class Method Details

.return_versionObject



32
33
34
# File 'lib/stackconnect.rb', line 32

def self.return_version
  @@VERSION
end

Instance Method Details



26
27
28
29
30
# File 'lib/stackconnect.rb', line 26

def retrieve_day_popular_tags(from_date)
  @@uri.path = '/2.1/tags'
  @@uri.query = ({ :fromdate => from_date, :site=>'stackoverflow', :sort => 'activity', :order=>'desc'}).to_query
  data = JSON.parse(@@uri.open.read)
end


20
21
22
23
24
# File 'lib/stackconnect.rb', line 20

def retrieve_most_popular_tags
  @@uri.path = '/2.1/tags'
  @@uri.query = ({ :order=>'desc', :sort=>'popular', :site=>@@site}).to_query
  data = JSON.parse(@@uri.open.read)
end

#retrieve_total_questions(from_date) ⇒ Object



13
14
15
16
17
18
# File 'lib/stackconnect.rb', line 13

def retrieve_total_questions(from_date)
  @@uri.path = '/2.1/questions'
  @@uri.query = ({:site=>@@site, :filter=>'!--Me6hWI5gUs', :fromdate=>from_date}).to_query
  data = JSON.parse(@@uri.open.read)
  count = data["total"]
end