Class: CliFormat::Presenter::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/cli_format/presenter/base.rb

Direct Known Subclasses

Csv, Dotenv, Equal, Info, Json, Space, Tab, Table

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, header, rows) ⇒ Base

Returns a new instance of Base.



5
6
7
8
9
# File 'lib/cli_format/presenter/base.rb', line 5

def initialize(options, header, rows)
  @options, @header, @rows = options, header, rows
  @empty_message = "No items found"
  @buffer = []
end

Instance Attribute Details

#empty_message=(value) ⇒ Object (writeonly)

Sets the attribute empty_message

Parameters:

  • value

    the value to set the attribute empty_message to.



4
5
6
# File 'lib/cli_format/presenter/base.rb', line 4

def empty_message=(value)
  @empty_message = value
end

#headerObject

Returns the value of attribute header.



3
4
5
# File 'lib/cli_format/presenter/base.rb', line 3

def header
  @header
end

#rowsObject

Returns the value of attribute rows.



3
4
5
# File 'lib/cli_format/presenter/base.rb', line 3

def rows
  @rows
end

Instance Method Details

#showObject



11
12
13
14
15
16
17
# File 'lib/cli_format/presenter/base.rb', line 11

def show
  if @rows.empty?
    puts @empty_message
  else
    puts text
  end
end