別のキーワード
ライブラリ
- ビルトイン (104)
- abbrev (12)
- base64 (36)
- benchmark (60)
- bigdecimal (48)
-
bigdecimal
/ ludcmp (12) -
bigdecimal
/ math (72) - cmath (78)
- digest (12)
- erb (60)
- etc (84)
- fiddle (36)
- fileutils (391)
- find (24)
- json (132)
- kconv (12)
- objspace (48)
- open-uri (16)
- open3 (168)
- openssl (12)
- pp (4)
- readline (12)
- shellwords (48)
- syslog (264)
- timeout (21)
-
webrick
/ htmlutils (12) -
webrick
/ httpauth (12) -
webrick
/ httpstatus (12) -
webrick
/ httputils (24) -
webrick
/ utils (24) -
win32
/ resolv (24)
クラス
-
Win32
:: Resolv (24)
モジュール
- Abbrev (12)
- Base64 (36)
- Benchmark (60)
- BigMath (96)
- CMath (78)
- Digest (12)
-
ERB
:: DefMethod (12) -
ERB
:: Util (48) - Etc (84)
- Fiddle (36)
- FileTest (48)
- FileUtils (391)
- Find (24)
- JSON (132)
- Kconv (12)
- Kernel (100)
- LUSolve (12)
- ObjectSpace (48)
- Open3 (168)
-
OpenSSL
:: ASN1 (12) - Readline (12)
- Shellwords (48)
- Syslog (240)
-
Syslog
:: Macros (24) - Timeout (21)
-
WEBrick
:: HTMLUtils (12) -
WEBrick
:: HTTPAuth (12) -
WEBrick
:: HTTPStatus (12) -
WEBrick
:: HTTPUtils (24) -
WEBrick
:: Utils (24)
キーワード
- BigDecimal (24)
- E (12)
-
LOG
_ MASK (12) -
LOG
_ UPTO (12) - PI (12)
- abbrev (12)
- alert (12)
-
allocation
_ sourcefile (12) -
allocation
_ sourceline (12) - atan (12)
- autoload (12)
-
basic
_ auth (12) - benchmark (12)
- bm (12)
- bmbm (12)
- capture2 (12)
- capture2e (12)
- capture3 (12)
- cbrt (6)
- cbrt! (6)
- cd (24)
- chdir (24)
- chmod (12)
-
chmod
_ R (12) - chown (12)
-
chown
_ R (12) - close (12)
- cmp (12)
-
compare
_ file (12) - confstr (12)
- copy (12)
- cos (12)
- cos! (6)
- cp (12)
-
cp
_ lr (7) -
cp
_ r (12) - crit (12)
- debug (12)
- decode (12)
- decode64 (12)
-
def
_ erb _ method (12) - dlunwrap (12)
- dlwrap (12)
- dump (12)
- emerg (12)
- encode64 (12)
- err (12)
- escape (12)
- exp (18)
- exp! (6)
- facility (12)
-
fast
_ generate (12) -
fast
_ unparse (12) - find (24)
- free (12)
- generate (12)
-
get
_ hosts _ path (12) -
get
_ resolv _ info (12) - getlogin (12)
- getservername (12)
- h (12)
- hexencode (12)
-
html
_ escape (12) - ident (12)
- identical? (12)
- info (12)
- install (12)
- isjis (12)
- link (12)
- ln (12)
-
ln
_ s (12) - load (24)
-
load
_ mime _ types (12) - log (36)
- log! (12)
- lusolve (12)
- makedirs (12)
- mask (12)
- mask= (12)
- measure (12)
-
memsize
_ of (12) -
mime
_ type (12) - mkdir (12)
-
mkdir
_ p (12) - mkpath (12)
- move (12)
- mv (12)
- notice (12)
- nprocessors (12)
- open (40)
- open! (12)
- opened? (12)
- parse (12)
- parse! (12)
- pipeline (12)
-
pipeline
_ r (24) -
pipeline
_ rw (24) -
pipeline
_ start (24) -
pipeline
_ w (24) - popen3 (24)
- pp (12)
-
pretty
_ generate (12) -
pretty
_ unparse (12) -
random
_ string (12) - readline (12)
- realtime (12)
-
reason
_ phrase (12) - remove (12)
-
remove
_ entry (12) - reopen (12)
-
require
_ relative (12) - restore (12)
- rm (12)
-
rm
_ r (12) - rmdir (12)
- setgid? (12)
- setuid? (12)
- shellescape (12)
- shelljoin (12)
- shellsplit (12)
- shellwords (12)
- sin (12)
- sin! (6)
- socket? (12)
- sqrt (18)
- sqrt! (6)
- sticky? (12)
- symlink (12)
- sysconf (12)
- sysconfdir (12)
- systmpdir (12)
- tan! (6)
- timeout (21)
- touch (12)
-
trace
_ object _ allocations (12) - u (12)
- uname (12)
- unparse (12)
- uptodate? (12)
-
url
_ encode (12) -
urlsafe
_ encode64 (12) - warning (12)
検索結果
先頭5件
- Open3
. # popen3(*cmd) {|stdin , stdout , stderr , wait _ thr| . . . } -> () - Benchmark
. # bm(label _ width = 0 , *labels) {|rep| . . . } -> [Benchmark :: Tms] - FileUtils
. # cp _ lr(src , dest , noop: nil , verbose: nil , dereference _ root: true , remove _ destination: false) - LUSolve
. # lusolve(a , b , ps , zero = 0 . 0) -> [BigDecimal] - Etc
. # uname -> {Symbol => String}
-
Open3
. # popen3(*cmd) {|stdin , stdout , stderr , wait _ thr| . . . } -> () (25.0) -
外部プログラム cmd を実行し、そのプロセスの標準入力、標準出力、標準エラー 出力に接続されたパイプと実行したプロセスを待つためのスレッドを 4 要素の 配列で返します。
...準エラー
出力に接続されたパイプと実行したプロセスを待つためのスレッドを 4 要素の
配列で返します。
require 'open3'
stdin, stdout, stderr, wait_thr = *Open3.popen3("/usr/bin/nroff -man")
@param cmd 実行するコマンドを指定します。
@retu......数にブロックを実行し、最後にパイプ
を close します。この場合はブロックの最後の式の結果を返します。
require 'open3'
Open3.popen3("read stdin; echo stdout; echo stderr >&2") {|stdin, stdout, stderr, wait_thr|
stdin.puts "stdin"
stdin.close......
require 'open3'
Open3.popen3({"foo" => "1", "bar" => "2"}, "env") {|i, o, e, t|
i.close
print o.read
}
#=> ...
foo=1
bar=2
Kernel.#spawnと同様に、引数リストの最後にオプションをハッシュ形式
で指定する事ができます。
例:
require... -
Benchmark
. # bm(label _ width = 0 , *labels) {|rep| . . . } -> [Benchmark :: Tms] (19.0) -
Benchmark.#benchmark メソッドの引数を簡略化したものです。
...します。
@param labels ブロックが Benchmark::Tms オブジェクトの配列を返す場合に指定します。
//emlist[][ruby]{
require 'benchmark'
n = 50000
Benchmark.bm do |x|
x.report { for i in 1..n; a = "1"; end }
x.report { n.times do ; a = "1"; end }
x.report { 1.upt......3333 0.000000 1.483333 ( 0.694605)
# 1.516667 0.000000 1.516667 ( 0.711077)
//}
以下のようにも書けます。
//emlist[][ruby]{
require 'benchmark'
n = 50000
Benchmark.bm(7) do |x|
x.report("for:") { for i in 1..n; a = "1"; end }
x.report("times:") { n.times do ; a = "1";.......533333 0.016667 1.550000 ( 0.735473)
# upto: 1.500000 0.016667 1.516667 ( 0.711239)
//}
集計を付けた場合
//emlist[][ruby]{
require 'benchmark'
n = 50000
Benchmark.bm(7, ">total:", ">avg:") do |x|
tf = x.report("for:") { for i in 1..n; a = "1"; end }
tt = x.report("time... -
FileUtils
. # cp _ lr(src , dest , noop: nil , verbose: nil , dereference _ root: true , remove _ destination: false) (19.0) -
src へのハードリンク dest を作成します。 src がディレクトリの場合、再帰的にリンクします。 dest がディレクトリの場合、src へのハードリンク dest/src を作成します。
...ruby にインストールする例][ruby]{
require 'fileutils'
FileUtils.rm_r site_ruby + '/mylib', force: true
FileUtils.cp_lr 'lib/', site_ruby + '/mylib'
//}
//emlist[様々なファイルを対象ディレクトリにリンクする例][ruby]{
require 'fileutils'
FileUtils.cp_lr %w(mail.rb fie......+ '/tmail'
FileUtils.cp_lr Dir.glob('*.rb'), '/home/aamine/lib/ruby', noop: true, verbose: true
//}
//emlist[内容をリンクする例][ruby]{
require 'fileutils'
# ディレクトリそのものではなく、ディレクトリの内容をリンクしたい場合は、
# 以下のようにな... -
LUSolve
. # lusolve(a , b , ps , zero = 0 . 0) -> [BigDecimal] (19.0) -
LU 分解を用いて、連立1次方程式 Ax = b の解 x を求めて返します。
...s LUSolve.#ludecomp の返り値を指定します。
@param zero 0.0 を表す値を指定します。
//emlist[][ruby]{
require 'bigdecimal'
require 'bigdecimal/util'
require 'bigdecimal/ludcmp'
include LUSolve
a = [['1.0', '2.0'], ['3.0', '1.0']].flatten.map(&:to_d)
# x = ['1.0', -1.0']
b = [... -
Etc
. # uname -> {Symbol => String} (13.0) -
uname(2) で取得したシステム情報を Hash で返します。
...とも :sysname, :nodename, :release, :version, :machine の
5 つのキーを持つ Hash を返します。
//emlist[例][ruby]{
require 'etc'
require 'pp'
pp Etc.uname
# => {:sysname=>"Linux",
# :nodename=>"boron",
# :release=>"2.6.18-6-xen-686",
# :version=>"#1 SMP Thu Nov 5... -
FileUtils
. # chmod(mode , list , options = {}) -> Array (13.0) -
ファイル list のパーミッションを mode に変更します。
...て返します。
//emlist[][ruby]{
# Absolute mode
require 'fileutils'
FileUtils.chmod(0644, %w(my.rb your.rb his.rb her.rb))
FileUtils.chmod(0755, 'somecommand')
FileUtils.chmod(0755, '/usr/bin/ruby', verbose: true)
# Symbolic mode
require 'fileutils'
FileUtils.chmod("u=wr,go=rr", %w(my.rb your.... -
FileUtils
. # chown _ R(user , group , list , options = {}) -> Array (13.0) -
list 以下のファイルの所有ユーザと所有グループを user と group へ再帰的に変更します。
...#options
@return list を配列として返します。
//emlist[][ruby]{
require 'fileutils'
FileUtils.chown 'root', 'staff', '/usr/local/bin/ruby'
FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), verbose: true
require 'fileutils'
FileUtils.chown_R 'www', 'www', '/var/www/htdocs'
FileUtils.ch... -
FileUtils
. # cp _ r(src , dest , options = {}) -> () (13.0) -
src を dest にコピーします。src がディレクトリであったら再帰的に コピーします。その際 dest がディレクトリなら dest/src にコピーします。
...#options
//emlist[][ruby]{
# installing ruby library "mylib" under the site_ruby
require 'fileutils'
FileUtils.rm_r(site_ruby + '/mylib', force: true)
FileUtils.cp_r('lib/', site_ruby + '/mylib')
# other sample
require 'fileutils'
FileUtils.cp_r(%w(mail.rb field.rb debug/), site_ruby + '/tmail')
Fi... -
JSON
. # dump(object , io = nil , limit = nil) -> String | IO (13.0) -
与えられたオブジェクトを JSON 形式の文字列に変換してダンプします。
...ストの深さが limit を越えた場合に発生します。
//emlist[例][ruby]{
require "json"
JSON.dump({ name: "tanaka", age: 19 }) # => "{\"name\":\"tanaka\",\"age\":19}"
//}
//emlist[例][ruby]{
require "json"
File.open("test.txt", "w") do |f|
JSON.dump([[[[[[[[[[]]]]]]]]]], f, 10)... -
Kernel
. # open(name , mode = & # 39;r& # 39; , perm = nil , options = {}) -> StringIO | Tempfile | IO (13.0) -
name が http:// や ftp:// で始まっている文字列なら URI のリソースを 取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。 返されるオブジェクトは OpenURI::Meta モジュールで extend されています。
...す。
Ruby2.7以降、open-uriにより拡張されたKernel.openでURLを開くときにwarningが表示されるようになりました。
require 'open-uri'
open("http://www.ruby-lang.org/") {|f|
# ...
}
#=> warning: calling URI.open via Kernel#open is deprecated, call URI.open di......Net::FTPError のサブクラスが発生します。詳しくは net/ftp
を参照して下さい。
例:
require 'open-uri'
sio = open('http://www.example.com') { |sio|
p sio.is_a?(OpenURI::Meta) # => true
p sio.content_type
puts sio.read
}... -
Kernel
. # open(name , mode = & # 39;r& # 39; , perm = nil , options = {}) {|ouri| . . . } -> object (13.0) -
name が http:// や ftp:// で始まっている文字列なら URI のリソースを 取得した上で StringIO オブジェクトまたは Tempfile オブジェクトとして返します。 返されるオブジェクトは OpenURI::Meta モジュールで extend されています。
...す。
Ruby2.7以降、open-uriにより拡張されたKernel.openでURLを開くときにwarningが表示されるようになりました。
require 'open-uri'
open("http://www.ruby-lang.org/") {|f|
# ...
}
#=> warning: calling URI.open via Kernel#open is deprecated, call URI.open di......Net::FTPError のサブクラスが発生します。詳しくは net/ftp
を参照して下さい。
例:
require 'open-uri'
sio = open('http://www.example.com') { |sio|
p sio.is_a?(OpenURI::Meta) # => true
p sio.content_type
puts sio.read
}...