Module: Superset::Display

Included in:
Request
Defined in:
lib/superset/display.rb

Instance Method Summary collapse

Instance Method Details

#display_headersObject



30
31
32
# File 'lib/superset/display.rb', line 30

def display_headers
  # optionally override this method to display custom headers
end

#headingsObject



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

#listObject



3
4
5
# File 'lib/superset/display.rb', line 3

def list
  puts table.to_s
end

#list_attributesObject

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/superset/display.rb', line 34

def list_attributes
  raise NotImplementedError.new("You must implement list_attributes.")
end

#resultObject

Raises:

  • (NotImplementedError)


38
39
40
# File 'lib/superset/display.rb', line 38

def result
  raise NotImplementedError.new("You must implement result.")
end

#rowsObject



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

#tableObject



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

#titleObject



21
22
23
# File 'lib/superset/display.rb', line 21

def title
  self.class.to_s
end