Class: Mercenary::Presenter

Inherits:
Object
  • Object
show all
Defined in:
lib/patches/mercenary_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commandObject

Returns the value of attribute command.



3
4
5
# File 'lib/patches/mercenary_presenter.rb', line 3

def command
  @command
end

Instance Method Details

#command_headerObject



23
24
25
26
27
# File 'lib/patches/mercenary_presenter.rb', line 23

def command_header
  header = "\n#{command.identity}"
  header << " -- #{command.description}" if command.description
  header
end

#command_options_presentationObject



16
17
18
19
20
21
# File 'lib/patches/mercenary_presenter.rb', line 16

def command_options_presentation
  return nil if command.options.empty?
  command_options = command.options
  command_options -= command.parent.options unless command.parent.nil?
  command_options.map(&:to_s).join("\n")
end

#options_presentationObject



5
6
7
8
# File 'lib/patches/mercenary_presenter.rb', line 5

def options_presentation
  return nil unless command_options_presentation || parent_command_options_presentation
  [command_options_presentation.cyan, parent_command_options_presentation].join("\n\n").rstrip
end

#parent_command_options_presentationObject



10
11
12
13
# File 'lib/patches/mercenary_presenter.rb', line 10

def parent_command_options_presentation
  return nil unless command.parent
  Presenter.new(command.parent).command_options_presentation
end