180件ヒット
[1-100件を表示]
(0.021秒)
別のキーワード
クラス
- OptionParser (180)
キーワード
- accept (12)
- load (12)
-
on
_ head (12) -
on
_ tail (12) - parse (24)
- parse! (12)
-
program
_ name= (12) - reject (12)
- separator (12)
- summarize (24)
-
summary
_ indent= (12) -
summary
_ width= (12)
検索結果
先頭5件
- OptionParser
# accept(klass , pat = / . * / ) {|str| . . . } -> () - OptionParser
# on _ tail(*arg , &block) -> self - OptionParser
# reject(klass) -> () - OptionParser
# summarize(to = [] , width = self . summary _ width , max = width - 1 , indent= self . summary _ indent) -> () - OptionParser
# summarize(to = [] , width = self . summary _ width , max = width - 1 , indent= self . summary _ indent) {|line| . . . } -> ()
-
OptionParser
# accept(klass , pat = / . * / ) {|str| . . . } -> () (33.0) -
OptionParser.accept と同様ですが、 登録したブロックはレシーバーに限定されます。
...はレシーバーに限定されます。
@param klass クラスオブジェクトを与えます。
@param pat match メソッドを持ったオブジェクト(Regexp オブジェクトなど)を与えます。
//emlist[例][ruby]{
require "optparse"
require "time"
opts = OptionParser.new
opts.......accept(Time) do |s,|
begin
Time.parse(s) if s
rescue
raise OptionParser::InvalidArgument, s
end
end
opts.on("-t", "--time [TIME]", Time) do |time|
p time.class # => Time
end
opts.parse!(ARGV)
//}... -
OptionParser
# on _ tail(*arg , &block) -> self (33.0) -
オプションを取り扱うためのブロックを自身の持つリストの最後に登録します。
...便利です。
@param arg OptionParser#on と同様です。
@param block OptionParser#on と同様です。
//emlist[例][ruby]{
require "optparse"
opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end
puts opts.help
#......-h, --help
//}
//emlist[例][ruby]{
require "optparse"
opts = OptionParser.new
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end
opts.on_tail("--version", "Show version") do
puts OptionParser::Version.join('.')
exit
end
//}
@see OptionParser#on, OptionParser#on_hea... -
OptionParser
# reject(klass) -> () (33.0) -
OptionParser#accept で登録したクラスとブロックを 自身から削除します。
...除します。
@param klass 自身から削除したいクラスを指定します。
//emlist[例][ruby]{
require "optparse"
require "time"
def parse(option_parser)
option_parser.on("-t", "--time [TIME]", Time) do |time|
p time.class
end
option_parser.parse(ARGV)
end
opts = OptionPar......ser.new
opts.accept(Time) do |s,|
begin
Time.parse(s) if s
rescue
raise OptionParser::InvalidArgument, s
end
end
parse(opts) # => Time
opts.reject(Time)
parse(opts) # => unsupported argument type: Time (ArgumentError)
//}... -
OptionParser
# summarize(to = [] , width = self . summary _ width , max = width - 1 , indent= self . summary _ indent) -> () (33.0) -
サマリを指定された to へと加えていきます。
...せん。
@param to サマリを出力するオブジェクトを指定します。to には << メソッドが定義されいる必要があります。
@param width サマリの幅を整数で指定します。
@param max サマリの最大幅を整数で指定します。
@param indent サマ......インデントを文字列で指定します。
//emlist[例][ruby]{
require "optparse"
opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end
opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n... -
OptionParser
# summarize(to = [] , width = self . summary _ width , max = width - 1 , indent= self . summary _ indent) {|line| . . . } -> () (33.0) -
サマリを指定された to へと加えていきます。
...せん。
@param to サマリを出力するオブジェクトを指定します。to には << メソッドが定義されいる必要があります。
@param width サマリの幅を整数で指定します。
@param max サマリの最大幅を整数で指定します。
@param indent サマ......インデントを文字列で指定します。
//emlist[例][ruby]{
require "optparse"
opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end
opts.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n... -
OptionParser
# parse(*args , into: nil) -> [String] (27.0) -
与えられた argv をパースします。 argv からオプションを取り除いたものを返します。
...る場合は、
OptionParser#order と同様に振舞います。
@param argv パースしたい引数を文字列の配列で指定します。
@param args パースしたい引数を順に文字列として与えます。
@param into オプションを格納するハッシュを指定します......ラスになります。
//emlist[例][ruby]{
require "optparse"
opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end
ARGV # => ["-i", "-u", "-h", "test"]
opts.parse(ARGV) # => ["test"]... -
OptionParser
# parse(argv , into: nil) -> [String] (27.0) -
与えられた argv をパースします。 argv からオプションを取り除いたものを返します。
...る場合は、
OptionParser#order と同様に振舞います。
@param argv パースしたい引数を文字列の配列で指定します。
@param args パースしたい引数を順に文字列として与えます。
@param into オプションを格納するハッシュを指定します......ラスになります。
//emlist[例][ruby]{
require "optparse"
opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end
ARGV # => ["-i", "-u", "-h", "test"]
opts.parse(ARGV) # => ["test"]... -
OptionParser
# banner=(heading) (21.0) -
サマリの最初に表示される文字列を指定します。
...サマリの最初に表示される文字列を指定します。
@param heading サマリの最初に表示される文字列を指定します。
//emlist[例][ruby]{
require "optparse"
options = {}
opts = OptionParser.new do |opts|
opts.banner = "Usage: example.rb [options]" # => "Usage: e......xample.rb [options]"
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
options[:verbose] = v
end
end
opts.banner # => "Usage: example.rb [options]"
//}... -
OptionParser
# on _ head(*arg , &block) -> self (21.0) -
オプションを取り扱うためのブロックを自身の持つリストの最初に登録します。
...録します。
@param arg OptionParser#on と同様です。
@param block OptionParser#on と同様です。
//emlist[例][ruby]{
require "optparse"
opts = OptionParser.new do |opts|
opts.on_head("-i", "--init")
opts.on("-u", "--update")
opts.on_tail("-h", "--help")
end
puts opts.help
#...