Class: GithubStats::CLI::SpaceSeperatedLinePerResultResultsView
- Inherits:
-
Object
- Object
- GithubStats::CLI::SpaceSeperatedLinePerResultResultsView
- Defined in:
- lib/github_stats/cli.rb
Overview
Transforms a result set into a space-seperated table the results hash keys becoming the table headers and line breaks between rows.
Instance Attribute Summary collapse
-
#results ⇒ Object
Returns the value of attribute results.
Instance Method Summary collapse
- #fields ⇒ Object
-
#initialize(results) ⇒ SpaceSeperatedLinePerResultResultsView
constructor
A new instance of SpaceSeperatedLinePerResultResultsView.
- #to_s ⇒ Object
Constructor Details
#initialize(results) ⇒ SpaceSeperatedLinePerResultResultsView
Returns a new instance of SpaceSeperatedLinePerResultResultsView.
49 50 51 |
# File 'lib/github_stats/cli.rb', line 49 def initialize(results) self.results = results end |
Instance Attribute Details
#results ⇒ Object
Returns the value of attribute results.
48 49 50 |
# File 'lib/github_stats/cli.rb', line 48 def results @results end |
Instance Method Details
#fields ⇒ Object
53 54 55 |
# File 'lib/github_stats/cli.rb', line 53 def fields results.keys end |
#to_s ⇒ Object
57 58 59 60 61 |
# File 'lib/github_stats/cli.rb', line 57 def to_s fields.join(' ') + "\n" + results.map do |result| fields.map(&result.method(:fetch)).join(' ') end.join("\n") end |