るりまサーチ

最速Rubyリファレンスマニュアル検索!
176件ヒット [1-100件を表示] (0.048秒)
トップページ > クエリ:String[x] > クエリ:tr[x] > クエリ:OPTS[x] > ライブラリ:optparse[x]

別のキーワード

  1. string []=
  2. string slice!
  3. string []
  4. string slice
  5. string gsub

クラス

キーワード

検索結果

<< 1 2 > >>

OptionParser#summary_indent -> String (263.0)

サマリを表示する時のインデントを文字列で返します。

...e "optparse"

opts
= OptionParser.new do |opts|
opts
.on_head("-i", "--init")
opts
.on("-u", "--update")
opts
.on_tail("-h", "--help")
end

opts
.summary_indent # => " "
opts
.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
opts
.summary_indent = " "
opts
.su...
...mmary_indent # => " "
opts
.summarize
# => [" -i, --init\n", " -u, --update\n", " -h, --help\n"]
//}...

OptionParser#ver -> String (251.0)

program_name、version と release から生成したバージョンを表す文字列を返します。

...例][ruby]{
require "optparse"

OptionParser.new do |opts|
opts
.banner = "Usage: example.rb [options]"
opts
.program_name = "Optparse Example"
opts
.version = [0, 1]
opts
.release = "2019-05-01"

opts
.on_tail("--version", "Show version") do
puts opts.ver # => "Optparse Example 0.1 (2019-0...
...5-01)"
exit
end

opts
.parse!(ARGV)
end
//}...

OptionParser#parse!(argv = self.default_argv) -> [String] (245.0)

与えられた argv をパースします。

...]{
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"]
ARGV # => ["-i", "-u", "-h", "test"]
opts
.parse!(ARGV...

OptionParser#parse!(argv = self.default_argv, into: nil) -> [String] (245.0)

与えられた argv をパースします。

...]{
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"]
ARGV # => ["-i", "-u", "-h", "test"]
opts
.parse!(ARGV...

OptionParser#parse(*args) -> [String] (240.0)

与えられた argv をパースします。 argv からオプションを取り除いたものを返します。

...ラスになります。

//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(*args, into: nil) -> [String] (240.0)

与えられた argv をパースします。 argv からオプションを取り除いたものを返します。

...ラスになります。

//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) -> [String] (240.0)

与えられた argv をパースします。 argv からオプションを取り除いたものを返します。

...ラスになります。

//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] (240.0)

与えられた argv をパースします。 argv からオプションを取り除いたものを返します。

...ラスになります。

//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#to_a -> [String] (239.0)

サマリの各行を要素とした配列を返します。

...行を要素とした配列を返します。

//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
.to_a # => ["Usage: test [options]", " -i, --init\n", " -u, --update\n",...

OptionParser#help -> String (234.0)

サマリの文字列を返します。

...します。

//emlist[例][ruby]{
require "optparse"

options = {}
opts
= OptionParser.new do |opts|
opts
.banner = "Usage: example.rb [options]"

opts
.on("-v", "--[no-]verbose", "Run verbosely") do |v|
options[:verbose] = v
end
end

puts opts.help

# => Usage: example.rb [options]
# -v...

絞り込み条件を変える

OptionParser#to_s -> String (234.0)

サマリの文字列を返します。

...します。

//emlist[例][ruby]{
require "optparse"

options = {}
opts
= OptionParser.new do |opts|
opts
.banner = "Usage: example.rb [options]"

opts
.on("-v", "--[no-]verbose", "Run verbosely") do |v|
options[:verbose] = v
end
end

puts opts.help

# => Usage: example.rb [options]
# -v...

OptionParser#banner -> String (233.0)

サマリの最初に表示される文字列を返します。

...返します。

//emlist[例][ruby]{
require "optparse"

options = {}
opts
= OptionParser.new do |opts|
opts
.banner = "Usage: example.rb [options]"

opts
.on("-v", "--[no-]verbose", "Run verbosely") do |v|
options[:verbose] = v
end
end

p opts.banner # => "Usage: example.rb [options]"
//}...

OptionParser#on(long, klass = String, desc = "") {|v| ...} -> self (229.0)

オプションを取り扱うためのブロックを自身に登録します。 ブロックはコマンドラインのパース時に、オプションが指定されていれば呼ばれます。

...インスタンス
に変換されてから、ブロックに渡されます。

opts
.on("-w", "--width N", Integer){|w|
p w.class #=> Integer
}
# ruby command --width=32

opts
.on("-o", "--overwrite VALUE", TrueClass){|boolean| ...}
# ruby command --overwrite yes

@param short ショ...
...場合に発生します。

=== デフォルトで利用可能な引数クラス

: Object
オプションの引数は変換されません。

: String
オプションの引数は変換されません。ただし、空文字列を指定すると
OptionParser::InvalidArgument が発生します...
...す。10進数のフォーマットを指定できます。

: TrueClass
tr
ue か false に変換されます。"yes" や "no"、"true" や "false"、"+"
や "-" を指定できます。オプションの引数を省略した場合は true になります。
また、"no-" をオプションの...
<< 1 2 > >>