class CommandLion::Command
Public Class Methods
new(&block)
click to toggle source
# File lib/command_lion/command.rb, line 10 def initialize(&block) self.instance_eval(&block) if block_given? end
Public Instance Methods
action(&block)
click to toggle source
@private
# File lib/command_lion/command.rb, line 85 def action(&block) return @action unless block_given? @action = block end
after(&block)
click to toggle source
@private
# File lib/command_lion/command.rb, line 97 def after(&block) return @after unless block_given? @after = block end
argument() { |argument| ... }
click to toggle source
@private
# File lib/command_lion/command.rb, line 41 def argument if arguments.respond_to?(:each) arguments.each do |argument| # first if block_given? yield argument return else return argument end end else if block_given? yield arguments return else return arguments end end nil end
arguments() { |argument| ... }
click to toggle source
@private
# File lib/command_lion/command.rb, line 64 def arguments if block_given? if @arguments.respond_to?(:each) arguments.each do |argument| yield argument end elsif @arguments.respond_to?(:readline) until arguments.eof? yield arguments.readline end elsif @arguments.nil? and !@default return else yield @arguments || @default end else @arguments || @default end end
before(&block)
click to toggle source
@private
# File lib/command_lion/command.rb, line 91 def before(&block) return @before unless block_given? @before = block end
flag(string = nil)
click to toggle source
@private
# File lib/command_lion/command.rb, line 30 def flag(string = nil) if string.nil? return @flags.short if @flags return nil end @flags = Flags.build do short string.to_s end end
flags(&block)
click to toggle source
@private
# File lib/command_lion/command.rb, line 24 def flags(&block) return @flags unless block_given? @flags = Flags.build(&block) end
option(index, &block)
click to toggle source
@private
# File lib/command_lion/command.rb, line 15 def option(index, &block) option = Option.new option.index = index option.instance_eval(&block) @options = {} unless @options @options[index] = option end