Class: Tabled
- Inherits:
-
Object
- Object
- Tabled
- Includes:
- BaseFileBuilder
- Defined in:
- lib/tabled.rb,
lib/helpers.rb,
lib/template.rb,
lib/content_shaper.rb,
lib/parsers/csv_parser.rb,
lib/parsers/json_parser.rb
Defined Under Namespace
Classes: CSVParser, ContentShaper, Helpers, JSONParser, Template
Constant Summary collapse
- DEFAULT_OPTIONS =
{ framed: true, row_separator: '-', titles: [] }.freeze
Instance Attribute Summary collapse
-
#columns_width ⇒ Object
Returns the value of attribute columns_width.
-
#content ⇒ Object
Returns the value of attribute content.
-
#data ⇒ Object
Returns the value of attribute data.
-
#data_without_options ⇒ Object
Returns the value of attribute data_without_options.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(data, **options) ⇒ Tabled
constructor
A new instance of Tabled.
- #print_to_console ⇒ Object
Methods included from BaseFileBuilder
Constructor Details
#initialize(data, **options) ⇒ Tabled
Returns a new instance of Tabled.
14 15 16 17 18 19 |
# File 'lib/tabled.rb', line 14 def initialize(data, **) @options = DEFAULT_OPTIONS.merge() @data = Tabled::Helpers.convert_to_required_structure(data) @columns_width = Tabled::Helpers.calculate_columns_width(data: data, options: @options) @content = Tabled::ContentShaper.new(data, @columns_width, @options).shape end |
Instance Attribute Details
#columns_width ⇒ Object
Returns the value of attribute columns_width.
12 13 14 |
# File 'lib/tabled.rb', line 12 def columns_width @columns_width end |
#content ⇒ Object
Returns the value of attribute content.
12 13 14 |
# File 'lib/tabled.rb', line 12 def content @content end |
#data ⇒ Object
Returns the value of attribute data.
12 13 14 |
# File 'lib/tabled.rb', line 12 def data @data end |
#data_without_options ⇒ Object
Returns the value of attribute data_without_options.
12 13 14 |
# File 'lib/tabled.rb', line 12 def @data_without_options end |
#options ⇒ Object
Returns the value of attribute options.
12 13 14 |
# File 'lib/tabled.rb', line 12 def @options end |
Instance Method Details
#print_to_console ⇒ Object
21 22 23 |
# File 'lib/tabled.rb', line 21 def print_to_console print content.join("\n") end |