Repository URL to install this package:
|
Version:
2.2.2-1 ▾
|
U:RDoc::NormalClass[iI"Object:ET@I"BasicObject;To:RDoc::Markup::Document:@parts[o;;[ :
@fileI"class.c;T:0@omit_headings_from_table_of_contents_below0o;;[ ; I"$ext/psych/lib/psych/core_ext.rb;T;
0o;;[ ; I"&ext/psych/lib/psych/deprecated.rb;T;
0o;;[ ; I"lib/irb/ext/use-loader.rb;T;
0o;;[ ; I"lib/rexml/xpath_parser.rb;T;
0o;;[o:RDoc::Markup::Paragraph;[I"KObject is the default root of all Ruby objects. Object inherits from ;TI"NBasicObject which allows creating alternate object hierarchies. Methods ;TI"Ion Object are available to all classes unless explicitly overridden.;To:RDoc::Markup::BlankLine o;;[I"MObject mixes in the Kernel module, making the built-in kernel functions ;TI"Oglobally accessible. Although the instance methods of Object are defined ;TI"Lby the Kernel module, we have chosen to document them here for clarity.;T@!o;;[I"MWhen referencing constants in classes inheriting from Object you do not ;TI"Mneed to use the full namespace. For example, referencing +File+ inside ;TI"4+YourClass+ will find the top-level File class.;T@!o;;[I"QIn the descriptions of Object's methods, the parameter <i>symbol</i> refers ;TI"Gto a symbol, which is either a quoted string or a Symbol (such as ;TI"<code>:name</code>).;T; I"
object.c;T;
0; 0;
0[ [U:RDoc::Constant[i I"SCRIPT_LINES__;TI"Object::SCRIPT_LINES__;T00o;;[o;;[I"NWhen a Hash is assigned to +SCRIPT_LINES__+ the contents of files loaded ;TI"Kafter the assignment will be added as an Array of lines with the file ;TI"name as the key.;T; I"ext/ripper/ripper.c;T;
0@?@cRDoc::NormalClass0U;
[i I"ENV;TI"Object::ENV;T00o;;[o;;[I";ENV is a Hash-like accessor for environment variables.;T@!o;;[I"*See ENV (the class) for more details.;T; I"hash.c;T;
0@M@@@0U;
[i I"
STDIN;TI"Object::STDIN;T00o;;[o;;[I"Holds the original stdin;T@!; I" io.c;T;
0@W@@@0U;
[i I"STDOUT;TI"Object::STDOUT;T00o;;[o;;[I"Holds the original stdout;T@!; @W;
0@W@@@0U;
[i I"STDERR;TI"Object::STDERR;T00o;;[o;;[I"Holds the original stderr;T@!; @W;
0@W@@@0U;
[i I" ARGF;TI"Object::ARGF;T00o;;[o;;[I"KARGF is a stream designed for use in scripts that process files given ;TI"6as command-line arguments or passed in via STDIN.;T@!o;;[I"+See ARGF (the class) for more details.;T; @W;
0@W@@@0U;
[i I"
OptParse;FI"Object::OptParse;T0I"OptionParser;To;;[$S:RDoc::Markup::Heading:
leveli: textI"OptionParser;T@!S;;i;I"Introduction;T@!o;;[I"POptionParser is a class for command-line option analysis. It is much more ;TI"Tadvanced, yet also easier to use, than GetoptLong, and is a more Ruby-oriented ;TI"solution.;T@!S;;i;I"
Features;T@!o:RDoc::Markup::List:
@type:NUMBER:@items[
o:RDoc::Markup::ListItem:@label0;[o;;[I"MThe argument specification and the code to handle it are written in the ;TI"same place.;To;;0;[o;;[I"MIt can output an option summary; you don't need to maintain this string ;TI"separately.;To;;0;[o;;[I"DOptional and mandatory arguments are specified very gracefully.;To;;0;[o;;[I"CArguments can be automatically converted to a specified class.;To;;0;[o;;[I"2Arguments can be restricted to a certain set.;T@!o;;[I"HAll of these features are demonstrated in the examples below. See ;TI")#make_switch for full documentation.;T@!S;;i;I"Minimal example;T@!o:RDoc::Markup::Verbatim;[I"require 'optparse'
;TI"
;TI"options = {}
;TI" OptionParser.new do |opts|
;TI"3 opts.banner = "Usage: example.rb [options]"
;TI"
;TI"? opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
;TI" options[:verbose] = v
;TI" end
;TI"end.parse!
;TI"
;TI"p options
;TI"p ARGV
;T:@format0S;;i;I"Generating Help;T@!o;;[I"ROptionParser can be used to automatically generate help for the commands you ;TI"write:;T@!o;;[$I"require 'optparse'
;TI"
;TI"!Options = Struct.new(:name)
;TI"
;TI"class Parser
;TI" def self.parse(options)
;TI"% args = Options.new("world")
;TI"
;TI"1 opt_parser = OptionParser.new do |opts|
;TI"7 opts.banner = "Usage: example.rb [options]"
;TI"
;TI"K opts.on("-nNAME", "--name=NAME", "Name to say hello to") do |n|
;TI" args.name = n
;TI" end
;TI"
;TI": opts.on("-h", "--help", "Prints this help") do
;TI" puts opts
;TI" exit
;TI" end
;TI"
end
;TI"
;TI"$ opt_parser.parse!(options)
;TI" return args
;TI" end
;TI" end
;TI"'options = Parser.parse %w[--help]
;TI"
;TI" #=>
;TI"& # Usage: example.rb [options]
;TI"D # -n, --name=NAME Name to say hello to
;TI"A # -h, --help Prints this help#
;T;0S;;i;I"Complete example;T@!o;;[I"SThe following example is a complete Ruby program. You can run it and see the ;TI"Seffect of specifying various options. This is probably the best way to learn ;TI" the features of +optparse+.;T@!o;;[tI"require 'optparse'
;TI"require 'optparse/time'
;TI"require 'ostruct'
;TI"require 'pp'
;TI"
;TI"class OptparseExample
;TI"
;TI"< CODES = %w[iso-2022-jp shift_jis euc-jp utf8 binary]
;TI"H CODE_ALIASES = { "jis" => "iso-2022-jp", "sjis" => "shift_jis" }
;TI"
;TI" #
;TI"4 # Return a structure describing the options.
;TI" #
;TI" def self.parse(args)
;TI"U # The options specified on the command line will be collected in *options*.
;TI"' # We set default values here.
;TI"" options = OpenStruct.new
;TI" options.library = []
;TI"! options.inplace = false
;TI"# options.encoding = "utf8"
;TI"' options.transfer_type = :auto
;TI"! options.verbose = false
;TI"
;TI"1 opt_parser = OptionParser.new do |opts|
;TI"7 opts.banner = "Usage: example.rb [options]"
;TI"
;TI" opts.separator ""
;TI". opts.separator "Specific options:"
;TI"
;TI"! # Mandatory argument.
;TI". opts.on("-r", "--require LIBRARY",
;TI"P "Require the LIBRARY before executing your script") do |lib|
;TI"$ options.library << lib
;TI" end
;TI"
;TI"8 # Optional argument; multi-line description.
;TI"2 opts.on("-i", "--inplace [EXTENSION]",
;TI"/ "Edit ARGV files in place",
;TI"E " (make backup if EXTENSION supplied)") do |ext|
;TI"$ options.inplace = true
;TI"+ options.extension = ext || ''
;TI"\ options.extension.sub!(/\A\.?(?=.)/, ".") # Ensure extension begins with dot.
;TI" end
;TI"
;TI"/ # Cast 'delay' argument to a Float.
;TI"R opts.on("--delay N", Float, "Delay N seconds before executing") do |n|
;TI" options.delay = n
;TI" end
;TI"
;TI"4 # Cast 'time' argument to a Time object.
;TI"[ opts.on("-t", "--time [TIME]", Time, "Begin execution at given time") do |time|
;TI"! options.time = time
;TI" end
;TI"
;TI"$ # Cast to octal integer.
;TI"F opts.on("-F", "--irs [OCTAL]", OptionParser::OctalInteger,
;TI"E "Specify record separator (default \\0)") do |rs|
;TI"+ options.record_separator = rs
;TI" end
;TI"
;TI" # List of arguments.
;TI"S opts.on("--list x,y,z", Array, "Example 'list' of arguments") do |list|
;TI"! options.list = list
;TI" end
;TI"
;TI"W # Keyword completion. We are specifying a specific set of arguments (CODES
;TI"W # and CODE_ALIASES - notice the latter is a Hash), and the user may provide
;TI", # the shortest unambiguous text.
;TI"= code_list = (CODE_ALIASES.keys + CODES).join(',')
;TI"J opts.on("--code CODE", CODES, CODE_ALIASES, "Select encoding",
;TI"5 " (#{code_list})") do |encoding|
;TI") options.encoding = encoding
;TI" end
;TI"
;TI"8 # Optional argument with keyword completion.
;TI"= opts.on("--type [TYPE]", [:text, :binary, :auto],
;TI"G "Select transfer type (text, binary, auto)") do |t|
;TI"' options.transfer_type = t
;TI" end
;TI"
;TI" # Boolean switch.
;TI"C opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
;TI"! options.verbose = v
;TI" end
;TI"
;TI" opts.separator ""
;TI", opts.separator "Common options:"
;TI"
;TI"N # No argument, shows at tail. This will print an options summary.
;TI" # Try it and see!
;TI"@ opts.on_tail("-h", "--help", "Show this message") do
;TI" puts opts
;TI" exit
;TI" end
;TI"
;TI": # Another typical switch to print the version.
;TI"8 opts.on_tail("--version", "Show version") do
;TI"& puts ::Version.join('.')
;TI" exit
;TI" end
;TI"
end
;TI"
;TI"! opt_parser.parse!(args)
;TI" options
;TI" end # parse()
;TI"
;TI""end # class OptparseExample
;TI"
;TI"+options = OptparseExample.parse(ARGV)
;TI"pp options
;TI"
pp ARGV
;T;0S;;i;I"Shell Completion;T@!o;;[I"AFor modern shells (e.g. bash, zsh, etc.), you can use shell ;TI")completion for command line options.;T@!S;;i;I"Further documentation;T@!o;;[I"QThe above examples should be enough to learn how to use this class. If you ;TI"Dhave any questions, file a ticket at http://bugs.ruby-lang.org.;T; I"lib/optparse.rb;T;
0@a@@@0U;
[i I"ParseError;FI"Object::ParseError;T0I"Racc::ParseError;To;;[ ; I"lib/racc/parser.rb;T;
0@i@@@0U;
[i I"Synchronizer_m;FI"Object::Synchronizer_m;T0I"Sync_m;Fo;;[o;;[I"<A module that provides a two-phase lock with a counter.;T; I"lib/sync.rb;T;
0@t@@@0U;
[i I"Synchronizer;FI"Object::Synchronizer;T0I" Sync;To;;[o;;[I"JA class that provides two-phase lock with a counter. See Sync_m for ;TI"
details.;T; @t;
0@t@@@0U;
[i I"ThWait;FI"Object::ThWait;T0I"ThreadsWait;To;;[
o;;[ I"RThis class watches for termination of multiple threads. Basic functionality ;TI"P(wait until specified threads have terminated) can be accessed through the ;TI"Mclass method ThreadsWait::all_waits. Finer control can be gained using ;TI"instance methods.;T@!o;;[I"
Example:;T@!o;;[I"3ThreadsWait.all_waits(thr1, thr2, ...) do |t|
;TI"1 STDERR.puts "Thread #{t} has terminated."
;TI" end
;TI"
;TI"'th = ThreadsWait.new(thread1,...)
;TI"'th.next_wait # next one to be done;T;0; I"lib/thwait.rb;T;
0@@@@0U;
[i I"TimeoutError;FI"Object::TimeoutError;T0I"Timeout::Error;Fo;;[o;;[I"8Raised by Timeout#timeout when the block times out.;T; I"lib/timeout.rb;T;
0@£@@@0U;
[i I"NIL;TI"Object::NIL;T00o;;[o;;[I"An alias of +nil+;T; @1;
0@1@@@0U;
[i I" TRUE;TI"Object::TRUE;T00o;;[o;;[I"An alias of +true+;T; @1;
0@1@@@0U;
[i I"
FALSE;TI"Object::FALSE;T00o;;[o;;[I"An alias of +false+;T; @1;
0@1@@@0U;
[i I" DATA;TI"Object::DATA;T00o;;[o;;[I"IDATA is a File that contains the data section of the executed file. ;TI"3To create a data section use <tt>__END__</tt>:;T@!o;;[I"$ cat t.rb
;TI"puts DATA.gets
;TI"
__END__
;TI"hello world!
;TI"
;TI"$ ruby t.rb
;TI"hello world!;T;0; I"ruby.c;T;
0@Ò@@@0U;
[i I" ARGV;TI"Object::ARGV;T00o;;[o;;[I"HARGV contains the command line arguments used to run ruby with the ;TI"7first value containing the name of the executable.;T@!o;;[I"EA library like OptionParser can be used to process command-line ;TI"arguments.;T; @Ò;
0@Ò@@@0U;
[i I"RUBY_VERSION;TI"Object::RUBY_VERSION;T00o;;[o;;[I" The running version of ruby;T; I"version.c;T;
0@ê@@@0U;
[i I"RUBY_RELEASE_DATE;TI"Object::RUBY_RELEASE_DATE;T00o;;[o;;[I"$The date this ruby was released;T; @ê;
0@ê@@@0U;
[i I"RUBY_PLATFORM;TI"Object::RUBY_PLATFORM;T00o;;[o;;[I"The platform for this ruby;T; @ê;
0@ê@@@0U;
[i I"RUBY_PATCHLEVEL;TI"Object::RUBY_PATCHLEVEL;T00o;;[o;;[I"KThe patchlevel for this ruby. If this is a development build of ruby ;TI"the patchlevel will be -1;T; @ê;
0@ê@@@0U;
[i I"RUBY_REVISION;TI"Object::RUBY_REVISION;T00o;;[o;;[I"$The SVN revision for this ruby.;T; @ê;
0@ê@@@0U;
[i I"RUBY_DESCRIPTION;TI"Object::RUBY_DESCRIPTION;T00o;;[o;;[I"@The full ruby version string, like <tt>ruby -v</tt> prints';T; @ê;
0@ê@@@0U;
[i I"RUBY_COPYRIGHT;TI"Object::RUBY_COPYRIGHT;T00o;;[o;;[I""The copyright string for ruby;T; @ê;
0@ê@@@0U;
[i I"RUBY_ENGINE;TI"Object::RUBY_ENGINE;T00o;;[o;;[I".The engine or interpreter this ruby uses.;T; @ê;
0@ê@@@0U;
[i I"TOPLEVEL_BINDING;TI"Object::TOPLEVEL_BINDING;T00o;;[o;;[I"'The Binding of the top level scope;T; I" vm.c;T;
0@4@@@0[[I"MakeMakefile;To;;[ ; I"lib/mkmf.rb;T;
0I"lib/mkmf.rb;T[I"Kernel;To;;[ ; @1;
0I"
object.c;T[[I"
class;T[[:public[[I"
yaml_tag;FI"$ext/psych/lib/psych/core_ext.rb;T[:protected[ [:private[ [I"
instance;T[[;[A[I"!~;T@@[I"<=>;T@@[I"===;T@@[I"=~;T@@[I"CSV;FI"lib/csv.rb;T[I"DelegateClass;FI"lib/delegate.rb;T[I"Digest;FI"ext/digest/lib/digest.rb;T[I"
class;T@@[I"
clone;T@@[I"dclone;FI"lib/rexml/xpath_parser.rb;T[I"default_src_encoding;FI"lib/irb/src_encoding.rb;T[I"define_singleton_method;TI"proc.c;T[I"display;TI" io.c;T[I"dup;T@@[I"
enum_for;TI"enumerator.c;T[I" eql?;T@@[I"extend;TI"eval.c;T[I"freeze;T@@[I"frozen?;T@@[I" hash;T@@[I"inspect;T@@[I"instance_of?;T@@[I"instance_variable_defined?;T@@[I"instance_variable_get;T@@[I"instance_variable_set;T@@[I"instance_variables;T@@[I"
is_a?;T@@[I"itself;T@@[I"
kind_of?;T@@[I"method;T@p[I"methods;T@@[I" nil?;T@@[I"object_id;TI" gc.c;T[I"private_methods;T@@[I"protected_methods;T@@[I"psych_to_yaml;F@I[I"public_method;T@p[I"public_methods;T@@[I"public_send;TI"vm_eval.c;T[I"remove_instance_variable;T@@[I"respond_to?;TI"vm_method.c;T[I"respond_to_missing?;T@°[I" send;T@«[I"singleton_class;T@@[I"singleton_method;T@p[I"singleton_methods;T@@[I"sysread;FI"*lib/webrick/httpservlet/cgi_runner.rb;T[I"
taint;T@@[I"
tainted?;T@@[I"tap;T@@[I"timeout;FI"lib/timeout.rb;T[I"to_enum;T@x[I" to_s;T@@[I"to_yaml;T@I[I"
trust;T@@[I"unknown;TI"lib/mathn.rb;T[I"untaint;T@@[I"untrust;T@@[I"untrusted?;T@@[I"xmp;FI"lib/irb/xmp.rb;T[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ; 0;
0[/@
I"enumerator.c;TI"eval.c;TI"ext/digest/lib/digest.rb;T@@@?I" gc.c;T@M@WI"lib/English.rb;TI"lib/csv.rb;TI"lib/debug.rb;TI"lib/delegate.rb;TI"lib/drb/drb.rb;T@I"lib/irb/src_encoding.rb;TI"lib/irb/xmp.rb;TI"lib/mathn.rb;T@:@aI"lib/pp.rb;T@iI"lib/rake.rb;TI"lib/rake/clean.rb;T@I"lib/rubygems/syck_hack.rb;T@t@@£I"lib/tracer.rb;TI"lib/un.rb;TI"*lib/webrick/httpservlet/cgi_runner.rb;TI"lib/yaml.rb;T@1I"parse.c;TI"proc.c;T@Ò@ê@4I"vm_eval.c;TI"vm_method.c;T@ýcRDoc::TopLevel