Class: ListFormatter
- Inherits:
-
Object
- Object
- ListFormatter
- Defined in:
- lib/list_formatter.rb
Overview
file: list_formatter.rb
Instance Attribute Summary collapse
-
#to_s ⇒ Object
readonly
Returns the value of attribute to_s.
Instance Method Summary collapse
-
#initialize(layout = '', a = [], title: 'Untitled List', field_marker: '$', width: 60) ⇒ ListFormatter
constructor
A new instance of ListFormatter.
Constructor Details
#initialize(layout = '', a = [], title: 'Untitled List', field_marker: '$', width: 60) ⇒ ListFormatter
Returns a new instance of ListFormatter.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/list_formatter.rb', line 9 def initialize(layout='', a=[], title: 'Untitled List', field_marker: '$', width: 60) top = "== #{title} ".ljust(width,'=') bottom = '=' * width @to_s = top + "\n\n" \ + format_rows(a, layout, field_marker).join("\n" + '-' * width \ + "\n\n") + "\n" + bottom end |
Instance Attribute Details
#to_s ⇒ Object (readonly)
Returns the value of attribute to_s.
7 8 9 |
# File 'lib/list_formatter.rb', line 7 def to_s @to_s end |