Class: CliFormat::Presenter
- Inherits:
-
Object
- Object
- CliFormat::Presenter
- Defined in:
- lib/cli_format/presenter.rb,
lib/cli_format/presenter/csv.rb,
lib/cli_format/presenter/tab.rb,
lib/cli_format/presenter/base.rb,
lib/cli_format/presenter/info.rb,
lib/cli_format/presenter/json.rb,
lib/cli_format/presenter/equal.rb,
lib/cli_format/presenter/space.rb,
lib/cli_format/presenter/table.rb,
lib/cli_format/presenter/dotenv.rb,
lib/cli_format/presenter/markdown.rb
Defined Under Namespace
Classes: Base, Csv, Dotenv, Equal, Info, Json, Markdown, Space, Tab, Table
Instance Attribute Summary collapse
-
#header ⇒ Object
Returns the value of attribute header.
-
#rows ⇒ Object
Returns the value of attribute rows.
Instance Method Summary collapse
-
#format ⇒ Object
Formats: tabs, markdown, json, csv, table, etc.
-
#initialize(options = {}) ⇒ Presenter
constructor
A new instance of Presenter.
- #strategy ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Presenter
Returns a new instance of Presenter.
4 5 6 7 |
# File 'lib/cli_format/presenter.rb', line 4 def initialize( = {}) @options = @rows = [] end |
Instance Attribute Details
#header ⇒ Object
Returns the value of attribute header.
3 4 5 |
# File 'lib/cli_format/presenter.rb', line 3 def header @header end |
#rows ⇒ Object
Returns the value of attribute rows.
3 4 5 |
# File 'lib/cli_format/presenter.rb', line 3 def rows @rows end |
Instance Method Details
#format ⇒ Object
Formats: tabs, markdown, json, csv, table, etc
30 31 32 |
# File 'lib/cli_format/presenter.rb', line 30 def format @options[:format] || ENV["CLI_FORMAT"] || CliFormat.default_format # table end |
#strategy ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/cli_format/presenter.rb', line 17 def strategy return @strategy if @strategy strategy_class = begin "CliFormat::Presenter::#{format.camelize}".constantize rescue NameError => e default = CliFormat.default_format puts "WARN: format not found: #{format}. Using default format: #{default}" "CliFormat::Presenter::#{default.camelize}".constantize end @strategy = strategy_class.new(@options, @header, @rows) end |