class Chid::Commands::StackOverflow

Public Instance Methods

run() click to toggle source
# File lib/chid/commands/stack_overflow.rb, line 28
def run
  text_to_search = text_to_search_from_options
  text_to_search = get_text_to_search if text_to_search.empty?

  questions = ::StackOverflowApi.questions(text_to_search)
  ::Paginator.new(questions).paginate { |question| question.summary }
end

Private Instance Methods

text_to_search_from_options() click to toggle source

Returns the TEXT_TO_SEARCH mapped from the values of the options attribute. Will remove all nil values and join the array of values into String

@return [String] Mapped values from options attribute

If the options does not exist, will return empty String #=> ""

@example Text to Search

options = {'-search' => ['base', 'two']}

text_to_search #=> 'base two'
# File lib/chid/commands/stack_overflow.rb, line 57
def text_to_search_from_options
  @text_to_search ||= self.class.arguments.map { |a| options[a] }.compact.join(' ')
end