Class: StackOverFlow

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/gaea/lib/stackoverflow.rb

Constant Summary collapse

PAGE_SIZE =

Page size

10

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keywords) ⇒ StackOverFlow

Create constructor for StackOverFlow object.

keywords - The keywords will match all questions.

Examples

StackOverFlow.new('Ruby on Rails')

Returns nothing



22
23
24
# File 'lib/gaea/lib/stackoverflow.rb', line 22

def initialize(keywords)
  @options = { query: { pagesize: PAGE_SIZE, q: keywords, accepted: true, site: 'stackoverflow' } }
end

Instance Attribute Details

#optionsObject (readonly)

Attribute reader



3
4
5
# File 'lib/gaea/lib/stackoverflow.rb', line 3

def options
  @options
end

Instance Method Details

#questionsObject

List of ten questions based on attributes.

Examples

stackoverflow = StackOverFlow.new('activerecord nomethod error', true)
stackoverflow.questions
# =>
  +---------------+-----------------------------------------------------------------------------------+-------------------------------------+-------------------------------------+
  | Owner         | Title                                                                             | Question                            | Accepted Answer                     |
  +---------------+-----------------------------------------------------------------------------------+-------------------------------------+-------------------------------------+
  | Daniel Cukier | Discover errors in Invalid Record factory girl                                    | http://stackoverflow.com/q/23374576 | http://stackoverflow.com/a/23374747 |
  | Chris Mendla  | Rails delete record fails                                                         | http://stackoverflow.com/q/35232445 | http://stackoverflow.com/a/35235143 |
  | Jorrin        | Manually assigning parent ID with has_many/belongs_to association in custom class | http://stackoverflow.com/q/35193155 | http://stackoverflow.com/a/35201406 |
  | simonmorley   | Rails i18n Attributes Not Working via JSON API                                    | http://stackoverflow.com/q/35113584 | http://stackoverflow.com/a/35117092 |
  | NeoP5         | Sonarqube 5.3: Error installing on Oracle 12 - columns missing                    | http://stackoverflow.com/q/34807593 | http://stackoverflow.com/a/35008747 |
  | kannet        | Invalid single-table inheritance type: dog is not a subclass of Pet               | http://stackoverflow.com/q/34988853 | http://stackoverflow.com/a/34989090 |
  | Brittany      | NoMethodError in Users#show error?                                                | http://stackoverflow.com/q/34980742 | http://stackoverflow.com/a/34980943 |
  | Mac           | Python POST binary data                                                           | http://stackoverflow.com/q/14365027 | http://stackoverflow.com/a/14448953 |
  | CuriousMind   | railstutorial.org, Chapter 6. unknown attribute: password                         | http://stackoverflow.com/q/12142374 | http://stackoverflow.com/a/12142417 |
  | Brittany      | Empty database, user already exists message?                                      | http://stackoverflow.com/q/34862365 | http://stackoverflow.com/a/34862683 |
  +---------------+-----------------------------------------------------------------------------------+-------------------------------------+-------------------------------------+

Returns the table



49
50
51
52
# File 'lib/gaea/lib/stackoverflow.rb', line 49

def questions
  # TODO: need to get more questions - Apply paginates
  parse_questions
end