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
13
# File 'lib/hammer_cli/help/definition/abstract_item.rb', line 9

def initialize(options = {})
  @id = options[:id]
  @indentation = options[:indentation]
  @richtext = options[:richtext] || false
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

#richtextObject (readonly)

Returns the value of attribute richtext.



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

def richtext
  @richtext
end

Class Method Details

.indent(content, indentation = nil) ⇒ Object



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

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)


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

def build_string
  raise NotImplementedError
end