Class: Archive::Tar::Minitar::Command::CommandPattern
- Inherits:
-
Object
- Object
- Archive::Tar::Minitar::Command::CommandPattern
show all
- Defined in:
- lib/archive/tar/minitar/command.rb
Defined Under Namespace
Classes: AbstractCommandError, CommandAlreadyExists, UnknownCommandError
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Class Attribute Details
.default ⇒ Object
Returns the value of attribute default.
253
254
255
|
# File 'lib/archive/tar/minitar/command.rb', line 253
def default
@default
end
|
Class Method Details
.<<(command) ⇒ Object
249
250
251
|
# File 'lib/archive/tar/minitar/command.rb', line 249
def <<(command)
add(command)
end
|
.[](cmd) ⇒ Object
278
279
280
|
# File 'lib/archive/tar/minitar/command.rb', line 278
def [](cmd)
self.command(cmd)
end
|
.add(command) ⇒ Object
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
# File 'lib/archive/tar/minitar/command.rb', line 232
def add(command)
command = command.new if command.kind_of?(Class)
@commands ||= {}
if @commands.has_key?(command.name)
raise CommandAlreadyExists
else
@commands[command.name] = command
end
if command.respond_to?(:altname)
unless @commands.has_key?(command.altname)
@commands[command.altname] = command
end
end
end
|
.command(command) ⇒ Object
270
271
272
273
274
275
276
|
# File 'lib/archive/tar/minitar/command.rb', line 270
def command(command)
if command?(command)
@commands[command]
else
@default
end
end
|
.command?(command) ⇒ Boolean
266
267
268
|
# File 'lib/archive/tar/minitar/command.rb', line 266
def command?(command)
@commands.has_key?(command)
end
|
.default_ioe(ioe = {}) ⇒ Object
282
283
284
285
286
287
|
# File 'lib/archive/tar/minitar/command.rb', line 282
def default_ioe(ioe = {})
ioe[:input] ||= $stdin
ioe[:output] ||= $stdout
ioe[:error] ||= $stderr
ioe
end
|
Instance Method Details
#[](args, opts = {}, ioe = {}) ⇒ Object
290
291
292
|
# File 'lib/archive/tar/minitar/command.rb', line 290
def [](args, opts = {}, ioe = {})
call(args, opts, ioe)
end
|
#call(args, opts = {}, ioe = {}) ⇒ Object
298
299
300
|
# File 'lib/archive/tar/minitar/command.rb', line 298
def call(args, opts = {}, ioe = {})
raise AbstractCommandError
end
|
#help ⇒ Object
302
303
304
|
# File 'lib/archive/tar/minitar/command.rb', line 302
def help
raise AbstractCommandError
end
|
#name ⇒ Object
294
295
296
|
# File 'lib/archive/tar/minitar/command.rb', line 294
def name
raise AbstractCommandError
end
|