Module: Superset::Display
- Included in:
- Request
- Defined in:
- lib/superset/display.rb
Instance Method Summary collapse
- #display_headers ⇒ Object
- #headings ⇒ Object
- #list ⇒ Object
- #list_attributes ⇒ Object
- #result ⇒ Object
- #rows ⇒ Object
- #table ⇒ Object
- #title ⇒ Object
Instance Method Details
#display_headers ⇒ Object
30 31 32 |
# File 'lib/superset/display.rb', line 30 def display_headers # optionally override this method to display custom headers end |
#headings ⇒ Object
25 26 27 28 |
# File 'lib/superset/display.rb', line 25 def headings headings = display_headers ? display_headers : list_attributes headings.map(&:to_s).map(&:humanize) end |
#list ⇒ Object
3 4 5 |
# File 'lib/superset/display.rb', line 3 def list puts table.to_s end |
#list_attributes ⇒ Object
34 35 36 |
# File 'lib/superset/display.rb', line 34 def list_attributes raise NotImplementedError.new("You must implement list_attributes.") end |
#result ⇒ Object
38 39 40 |
# File 'lib/superset/display.rb', line 38 def result raise NotImplementedError.new("You must implement result.") end |
#rows ⇒ Object
15 16 17 18 19 |
# File 'lib/superset/display.rb', line 15 def rows result.map do |d| list_attributes.map { |la| d[la].to_s } end end |
#table ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/superset/display.rb', line 7 def table Terminal::Table.new( title: title, headings: headings, rows: rows ) end |
#title ⇒ Object
21 22 23 |
# File 'lib/superset/display.rb', line 21 def title self.class.to_s end |