Class: Fuelcell::Help::BaseFormatter

Inherits:
Object
  • Object
show all
Defined in:
lib/fuelcell/help/base_formatter.rb

Overview

Hold common functionality and information needed by all formatters

Constant Summary collapse

DEFAULT_WIDTH =
80
DEFAULT_PADDING =
4

Instance Attribute Summary collapse

Instance Method Summary collapse

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_widthObject (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

#paddingObject (readonly)

Returns the value of attribute padding.



7
8
9
# File 'lib/fuelcell/help/base_formatter.rb', line 7

def padding
  @padding
end

#widthObject (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