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.



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

def initialize(command_class)
  @command_class = command_class
end

Instance Attribute Details

#command_classObject (readonly)

Returns the value of attribute command_class.



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

def command_class
  @command_class
end

Class Method Details

.proxy(method_name) ⇒ Object



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

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

Instance Method Details

#dateObject



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

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

#full_nameObject



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

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

  stack.join(' ')
end

#paragraphsObject



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

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

#short_descriptionObject



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

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

#short_nameObject



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

def short_name
  command_class.command_name
end

#subcommandsObject



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

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