Class: Fuelcell::Help::BaseFormatter
- Inherits:
-
Object
- Object
- Fuelcell::Help::BaseFormatter
- Defined in:
- lib/fuelcell/help/base_formatter.rb
Overview
Hold common functionality and information needed by all formatters
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_WIDTH =
80
- DEFAULT_PADDING =
4
Instance Attribute Summary collapse
-
#max_width ⇒ Object
readonly
Returns the value of attribute max_width.
-
#padding ⇒ Object
readonly
Returns the value of attribute padding.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
-
#initialize(config = {}) ⇒ BaseFormatter
constructor
A new instance of BaseFormatter.
- #long_opt(data, no_opt = '') ⇒ Object
- #short_opt(data, no_opt = '') ⇒ Object
Constructor Details
#initialize(config = {}) ⇒ BaseFormatter
Returns a new instance of BaseFormatter.
9 10 11 12 13 |
# File 'lib/fuelcell/help/base_formatter.rb', line 9 def initialize(config = {}) @width = config[:width] || DEFAULT_WIDTH @padding = config[:padding] || DEFAULT_PADDING @max_width = width - padding end |
Instance Attribute Details
#max_width ⇒ Object (readonly)
Returns the value of attribute max_width.
7 8 9 |
# File 'lib/fuelcell/help/base_formatter.rb', line 7 def max_width @max_width end |
#padding ⇒ Object (readonly)
Returns the value of attribute padding.
7 8 9 |
# File 'lib/fuelcell/help/base_formatter.rb', line 7 def padding @padding end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
7 8 9 |
# File 'lib/fuelcell/help/base_formatter.rb', line 7 def width @width end |
Instance Method Details
#long_opt(data, no_opt = '') ⇒ Object
19 20 21 |
# File 'lib/fuelcell/help/base_formatter.rb', line 19 def long_opt(data, no_opt = '') data[:long].nil? ? no_opt : "--#{data[:long]}=#{data[:long].upcase}" end |
#short_opt(data, no_opt = '') ⇒ Object
15 16 17 |
# File 'lib/fuelcell/help/base_formatter.rb', line 15 def short_opt(data, no_opt = '') data[:short].nil? ? no_opt : "-#{data[:short]}" end |