るりまサーチ

最速Rubyリファレンスマニュアル検索!
377件ヒット [1-100件を表示] (0.020秒)

別のキーワード

  1. _builtin puts
  2. csv puts
  3. stringio puts
  4. io puts
  5. xmp puts

検索結果

<< 1 2 3 ... > >>

BasicObject#! -> bool (18143.0)

オブジェクトを真偽値として評価し、その論理否定を返します。

...f !
@count += 1
super
end
end

recorder = NegationRecorder.new
!
recorder
!
!!!!!!recorder
puts
'hoge' if !recorder

puts
recorder.count #=> 3
//}

//emlist[例][ruby]{
class AnotherFalse < BasicObject
def !
true
end
end
another_false = AnotherFalse.new

# another_falseは*真*
puts
...

Kernel.#exit!(status = false) -> () (6136.0)

Rubyプログラムの実行を即座に終了します。 status として整数が与えられた場合、その値を Ruby コマンドの終了ステータスとします。 デフォルトの終了ステータスは 1 です。

...定したとみなされます。この値はCレベルの定数
EXIT_SUCCESS、EXIT_FAILURE の値なので、正確には環境依存です。

exit! は exit とは違って、例外処理などは一切行ないませ
ん。 Kernel.#fork の後、子プロセスを終了させる時などに用...
...与えます。

//emlist[例][ruby]{
STDOUT.sync = true #表示前に終了しないようにする
puts
'start'
begin
puts
'start1...'
exit!
ensure
puts
'end1...' #実行されない
end
puts
'end' #実行されない

#=> start
# start1...
#終了ステータス:1
//}

@see Kernel.#exit,K...

BasicObject#!=(other) -> bool (6106.0)

オブジェクトが other と等しくないことを判定します。

...返します。
このため、サブクラスで BasicObject#== を再定義しても != とは自動的に整合性が
とれるようになっています。

ただし、 BasicObject#!= 自身や BasicObject#! を再定義した際には、ユーザーの責任で
整合性を保たなくては...
...icObject#==, BasicObject#!

//emlist[例][ruby]{
class NonequalityRecorder < BasicObject
def initialize
@count = 0
end
attr_reader :count

def !=(other)
@count += 1
super
end
end
recorder = NonequalityRecorder.new

recorder != 1
puts
'hoge' if recorder != "str"

p recorder.coun...

Syslog.#open!(ident=$0, options=Syslog::LOG_PID|Syslog::LOG_CONS, facility=Syslog::LOG_USER) { |syslog| ... } -> self (6106.0)

開いていた syslog を最初にクローズする点を除いてSyslog.#open と同じです。

...::LOG_WARNING, "the sky is falling in %d seconds!", 100)
begin
Syslog.open!("syslogtest2")
Syslog.log(Syslog::LOG_WARNING, "the sky is falling in %d seconds!", 200)
rescue RuntimeError => err
# RuntimeError は発生しない。
puts
err
end
File.foreach('/var/log/system.log'...

Syslog.#reopen(ident=$0, options=Syslog::LOG_PID|Syslog::LOG_CONS, facility=Syslog::LOG_USER) { |syslog| ... } -> self (3006.0)

開いていた syslog を最初にクローズする点を除いてSyslog.#open と同じです。

...::LOG_WARNING, "the sky is falling in %d seconds!", 100)
begin
Syslog.open!("syslogtest2")
Syslog.log(Syslog::LOG_WARNING, "the sky is falling in %d seconds!", 200)
rescue RuntimeError => err
# RuntimeError は発生しない。
puts
err
end
File.foreach('/var/log/system.log'...

絞り込み条件を変える

yaml (150.0)

構造化されたデータを表現するフォーマットであるYAML (YAML Ain't Markup Language) を扱うためのライブラリです。

...YAML
version: 3
log: |
アブストラクトを書いた。

YAML_EOT

YAML.load_stream(strio_r).sort_by{ |a| a["version"] }.each do |obj|
puts
"version %d\ntime %s\ntarget:%s\n%s\n" % obj.values_at("version", "time", "target", "log")
end

# =>
# version 3
# time 2008-02-24 17:00:35 +09...
...扱う事ができます。


=== タグの指定

!
ruby/sym :foo などのようにタグを指定することで、読み込み時に記述した値
の型を指定できます。

//emlist[例][ruby]{
require 'yaml'
p YAML.load(<<~EOS)
---
!
ruby/sym :foo
EOS
# => :foo
//}

yaml では、Ruby...
...* !ruby/array: Array オブジェクト
* !ruby/class: Class オブジェクト
* !ruby/hash: Hash オブジェクト
* !ruby/module: Module オブジェクト
* !ruby/regexp: Regexp オブジェクト
* !ruby/range: Range オブジェクト
* !ruby/string: String オブジェクト
* !ru...

ruby 1.6 feature (138.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...)

: 2002-07-11 String#slice!

範囲外の文字列を指定したときに例外を返す場合がありましたが、常に nil
を返すようになりました。(String#[]やString#slice と同じ結果を返すと
いうことです)

p "foo".slice!("bar") # <- 以前から...
...こちらは nil を返していた
p "foo".slice!(5,10)

=> ruby 1.6.7 (2002-03-01) [i586-linux]
nil
-:2:in `slice!': index 5 out of string (IndexError)
from -:2
=> ruby 1.6.7 (2002-08-01) [i586-linux]
nil
nil

: 20...
...シグナルを送らないと終了しない不具合が修正さ
れました。((<ruby-bugs-ja:PR#223>))

trap(:TERM, "EXIT")

END{
puts
"exit"
}

Thread.start { Thread.stop }
sleep

: 2002-04-17: Regexp#inspect

((<ruby-bugs-ja:PR#222>))

p %r{\/}

=> ruby 1...

クラス/メソッドの定義 (120.0)

クラス/メソッドの定義 * クラス/メソッドの定義: * class * singleton_class * module * method * operator * nest_method * eval_method * singleton_method * class_method * limit * 定義に関する操作: * alias * undef * defined

...して他の言語における「関数」のように使えます。

//emlist[例][ruby]{
def hello # 引数のないメソッド。
puts
"Hello, world!"
end

def foo(a, b) # 引数のあるメソッド。括弧を省いてdef foo a, bとも
a + 3 * b
end
//}

メソッド名としては...
..., y = $gvar) # 確かに定義時には$gvar == 3だが
10 * x + y
end
$gvar = 7
# 呼び出し時の$gvarの値が使われる
p bar(5) #=> 57 (!= 53)
//}

仮引数の直前に * がある場合には残りの実引数
(後述の post 引数を除く)
はみな配列とし てこの引数に...
...t[例][ruby]{
def foo(x, *xs)
puts
"#{x} : #{xs.inspect}" # Object#inspect は p のような詳細な内部表示
end
foo(1) #=> 1 : []
foo(1, 2) #=> 1 : [2]
foo(1, 2, 3) #=> 1 : [2, 3]

def bar(x, *) # 残りの引数を単に無視したいとき
puts
"#{x}"
end
bar(1) #=...

ruby 1.8.4 feature (84.0)

ruby 1.8.4 feature ruby 1.8.4 での ruby 1.8.3 からの変更点です。

...ns invalid symbol representations:

puts
:"!".inspect
puts
:"=".inspect
puts
:"0".inspect
puts
:"$1".inspect
puts
:"@1".inspect
puts
:"@@1".inspect
puts
:"@".inspect
puts
:"@@".inspect

# => r...
...5-09-21) [i686-linux]
:!
:=
:0
:$1
:@1
:@@1
:@
:@@
# => ruby 1.8.4 (2005-12-22) [i686-linux]
:"!"
:"="...
...imal symbol representations:
puts
:foo!.inspect
puts
:bar?.inspect

# => ruby 1.8.3 (2005-09-21) [i686-linux]
:"foo!"
:"bar?"
# => ruby 1.8.4 (2005-12-22) [i686-linux]
:foo!
:bar?...
<< 1 2 3 ... > >>