Class: TwitterHashtag::Formatter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ Formatter

Returns a new instance of Formatter.



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

def initialize(response)
  @results = response['results']
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



10
11
12
# File 'lib/twitter_hashtag/formatter.rb', line 10

def results
  @results
end

Instance Method Details

#formatObject



12
13
14
15
16
17
18
19
20
# File 'lib/twitter_hashtag/formatter.rb', line 12

def format
  if results.empty?
    puts 'None found.'
    exit 1
  else
    puts 'Results:'
    TwitterHashtag::Tweet.output(results)
  end
end