class Scripting::Application

Public Class Methods

new() click to toggle source
# File lib/scripting/application.rb, line 11
def initialize
  clear_switches!
  clear_options!
  clear_work!
  clear_help!
end

Public Instance Methods

clear_help!() click to toggle source
# File lib/scripting/application.rb, line 54
def clear_help!
  @help = [lambda { $stderr.puts @switches }]
end
clear_options!() click to toggle source
# File lib/scripting/application.rb, line 36
def clear_options!
  @options = Options.new
end
clear_switches!() click to toggle source
# File lib/scripting/application.rb, line 27
def clear_switches!
  @switches = Parser.new(self)
end
clear_work!() click to toggle source
# File lib/scripting/application.rb, line 45
def clear_work!
  @work = []
end
context() click to toggle source
# File lib/scripting/application.rb, line 18
def context
  self
end
describe(&blk) click to toggle source
# File lib/scripting/application.rb, line 22
def describe &blk
  instance_eval &blk if block_given?
  self
end
help(&blk) click to toggle source
# File lib/scripting/application.rb, line 58
def help &blk
  @help << blk if block_given?
  @help
end
help!() click to toggle source
# File lib/scripting/application.rb, line 63
def help!
  @help.each(&:call)
end
options(&blk) click to toggle source
# File lib/scripting/application.rb, line 40
def options &blk
  @options.describe &blk if block_given?
  @options
end
parse!(args) click to toggle source
# File lib/scripting/application.rb, line 67
def parse! args
  switches.parse! args
  args
end
run!(*args) click to toggle source
# File lib/scripting/application.rb, line 72
def run! *args
  if args.first.kind_of? Array
    args.flatten!
  end
  parse! args
  work.each { |work| instance_exec(*args, &work) }
end
switches(&blk) click to toggle source
# File lib/scripting/application.rb, line 31
def switches &blk
  @switches.instance_eval &blk if block_given?
  @switches
end
work(&blk) click to toggle source
# File lib/scripting/application.rb, line 49
def work &blk
  @work << blk if block_given?
  @work
end