Class: Ame::Root
Overview
Root of a hierarchy of Classes. This class should be subclassed by the root of your command-line interface.
Class Method Summary collapse
-
.basename ⇒ String
An empty string.
-
.call(method, arguments = nil, options = nil) ⇒ self
Call METHOD with ARGUMENTS and OPTIONS on a new instance of the receiver.
-
.help(help = nil) ⇒ #method, ...
Sets the HELP object to use for displaying usage information, or returns it if HELP is nil.
-
.process(method = File.basename($0), arguments = ARGV) ⇒ self
Process ARGUMENTS as a list of options and arguments, then call METHOD with the results of this processing on a new instance of the receiver.
-
.version(version = nil) ⇒ String
Sets or returns, depending on if VERSION is nil or not, the version of the receiver.
Methods inherited from Class
description, fullname, methods
Class Method Details
.basename ⇒ String
Returns An empty string.
148 149 150 |
# File 'lib/ame-1.0/root.rb', line 148 def basename '' end |
.call(method, arguments = nil, options = nil) ⇒ self
Call METHOD with ARGUMENTS and OPTIONS on a new instance of the receiver. This method catches AbortAllProcessing.
139 140 141 142 143 144 |
# File 'lib/ame-1.0/root.rb', line 139 def call(method, arguments = nil, = nil) catch Ame::AbortAllProcessing do super end self end |
.help(help = nil) ⇒ #method, ...
Sets the HELP object to use for displaying usage information, or returns it if HELP is nil. The default is to use a Help::Terminal object.
104 105 106 107 |
# File 'lib/ame-1.0/root.rb', line 104 def help(help = nil) super if help @help ||= Ame::Help::Terminal.new end |
.process(method = File.basename($0), arguments = ARGV) ⇒ self
Process ARGUMENTS as a list of options and arguments, then call METHOD with the results of this processing on a new instance of the receiver. This method catches AbortAllProcessing. Any errors will be caught and reported using help#error.
125 126 127 128 129 130 131 132 |
# File 'lib/ame-1.0/root.rb', line 125 def process(method = File.basename($0), arguments = ARGV) catch Ame::AbortAllProcessing do super end self rescue => e help.error method, e end |
.version(version = nil) ⇒ String
Sets or returns, depending on if VERSION is nil or not, the version of the receiver. The version may be used by help to output version information.
114 115 116 117 |
# File 'lib/ame-1.0/root.rb', line 114 def version(version = nil) return @version = version if version @version end |