Class: Climate::Help::Man::Presenter

Inherits:
Object
  • Object
show all
Defined in:
lib/climate/help/man.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(command_class) ⇒ Presenter

Returns a new instance of Presenter.



49
50
51
# File 'lib/climate/help/man.rb', line 49

def initialize(command_class)
  @command_class = command_class
end

Instance Attribute Details

#command_classObject (readonly)

Returns the value of attribute command_class.



53
54
55
# File 'lib/climate/help/man.rb', line 53

def command_class
  @command_class
end

Class Method Details

.proxy(method_name) ⇒ Object



43
44
45
46
47
# File 'lib/climate/help/man.rb', line 43

def self.proxy(method_name)
  define_method(method_name) do
    @command_class.send(method_name)
  end
end

Instance Method Details

#dateObject



72
# File 'lib/climate/help/man.rb', line 72

def date         ; Date.today.strftime('%b, %Y') ; end

#full_nameObject



57
58
59
60
61
62
63
64
65
66
# File 'lib/climate/help/man.rb', line 57

def full_name
  stack = []
  command_ptr = command_class
  while command_ptr
    stack.unshift(command_ptr.name)
    command_ptr = command_ptr.parent
  end

  stack.join(' ')
end

#paragraphsObject



80
81
82
# File 'lib/climate/help/man.rb', line 80

def paragraphs
  command_class.description.split("\n\n")
end

#short_descriptionObject



84
85
86
# File 'lib/climate/help/man.rb', line 84

def short_description
  command_class.description.split(".").first
end

#short_nameObject



68
69
70
# File 'lib/climate/help/man.rb', line 68

def short_name
  command_class.name
end

#subcommandsObject



88
89
90
# File 'lib/climate/help/man.rb', line 88

def subcommands
  command_class.subcommands.map {|c| self.class.new(c) }
end