Class: HammerCLI::Help::AbstractItem

Inherits:
Object
  • Object
show all
Defined in:
lib/hammer_cli/help/definition/abstract_item.rb

Direct Known Subclasses

List, Section, Text

Constant Summary collapse

INDENT_STEP =
2

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ AbstractItem

Returns a new instance of AbstractItem.



9
10
11
12
# File 'lib/hammer_cli/help/definition/abstract_item.rb', line 9

def initialize(options = {})
  @id = options[:id]
  @indentation = options[:indentation]
end

Instance Attribute Details

#definitionObject

Returns the value of attribute definition.



7
8
9
# File 'lib/hammer_cli/help/definition/abstract_item.rb', line 7

def definition
  @definition
end

#idObject (readonly)

Returns the value of attribute id.



6
7
8
# File 'lib/hammer_cli/help/definition/abstract_item.rb', line 6

def id
  @id
end

Class Method Details

.indent(content, indentation = nil) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/hammer_cli/help/definition/abstract_item.rb', line 18

def self.indent(content, indentation = nil)
  indentation ||= ' ' * INDENT_STEP
  content = content.split("\n") unless content.is_a? Array
  content.map do |line|
    (indentation + line).rstrip
  end.join("\n")
end

Instance Method Details

#build_stringObject

Raises:

  • (NotImplementedError)


14
15
16
# File 'lib/hammer_cli/help/definition/abstract_item.rb', line 14

def build_string
  raise NotImplementedError
end