るりまサーチ

最速Rubyリファレンスマニュアル検索!
318件ヒット [1-100件を表示] (0.024秒)
トップページ > クエリ:ref[x] > クエリ:puts[x]

別のキーワード

  1. fiddle ref
  2. pointer ref
  3. entity ref
  4. rexml/document ref
  5. _builtin _id2ref

検索結果

<< 1 2 3 ... > >>

ARGF.class#puts(*arg) -> nil (18113.0)

引数と改行を順番に処理対象のファイルに出力します。 引数がなければ改行のみを出力します。

...力します。
引数がなければ改行のみを出力します。

c:ARGF#inplace時にのみ使用できます。
また $stdout への代入の影響を受けません。
それ以外は Kernel.#puts と同じです。

@param arg 出力するオブジェクトを任意個指定します。...

Module#refine(klass) { ... } -> Module (6112.0)

引数 klass で指定したクラスまたはモジュールだけに対して、ブロックで指定した機能を提供で きるモジュールを定義します。定義した機能は Module#refine を使用せずに直 接 klass に対して変更を行う場合と異なり、限られた範囲のみ有効にできます。 そのため、既存の機能を局所的に修正したい場合などに用いる事ができます。

...義した機能は Module#refine を使用せずに直
接 klass に対して変更を行う場合と異なり、限られた範囲のみ有効にできます。
そのため、既存の機能を局所的に修正したい場合などに用いる事ができます。

ref
inements 機能の詳細に...
...ついては以下を参照してください。

* https://magazine.rubyist.net/articles/0041/0041-200Special-refinement.html
* https://docs.ruby-lang.org/en/master/syntax/refinements_rdoc.html

定義した機能は main.using, Module#using を実行した場合のみ
有効になります。

@...
...で指定した機能を持つ無名のモジュールを返します。

//emlist[例][ruby]{
class C
def foo
puts
"C#foo"
end
end

module M
ref
ine C do
def foo
puts
"C#foo in M"
end
end
end

x = C.new
x.foo # => "C#foo"

using M

x = C.new
x.foo # => "C#foo in M"
//}

@se...

ReFe (6024.0)

ReFe ReFeについては http://i.loveruby.net/ja/prog/refe.html をご覧ください。

...ReFe
ReF
eについては
http://i.loveruby.net/ja/prog/refe.html
をご覧ください。

=== Gems版

Gemsをお使いの方は、以下のコマンドを実行する事でインストールできます。
(41478)

$ gem install refe2

以下のコマンドでデータベースを構築しま...
...索ツール ReFe のデータ構築について

最新 Ruby リファレンスマニュアル用に ReFe のデータを構築するには以下の
手順で行います。(詳細は ReFe の README を参照してください)

(1) http://i.loveruby.net/ja/prog/refe.html から ReFe の基本セ...
...mkrefe_rubyrefm -d /usr/local/share/refe *.rd

/usr/local/share/refe 下に以下のディレクトリとファイルができます。

class_document/ method_document/
class_document_comp method_document_comp

(4) 後は使うだけです。

ref
e IO puts...

Rubyで使われる記号の意味(正規表現の複雑な記号は除く) (3764.0)

Rubyで使われる記号の意味(正規表現の複雑な記号は除く) ex q num per and or  plus minus ast slash hat sq  period comma langl rangl eq tilde  dollar at under lbrarbra  lbra2rbra2 lbra3rbra3 dq colon ac  backslash semicolon

...一種。d:spec/literal#percent。ダブルクォート文字列で %Q!STRING! と同じ。
//emlist{
p %!nomad! #=> "nomad"
//}

: % ruby -e "puts 'Hello'"

コマンドラインへの入力を示す。rubyスクリプト上で入力を行うには `command` や system(command) などと書く...
...たは def -@

単項演算子 +X や -X を定義するときの表記法。
//emlist{
class Symbol
def +@
self.upcase
end
end

puts
(+:joke) #=> JOKE
//}

===[a:under] _

: xxx_yyy

識別子の中では小文字と同じ扱い

: 123_456

文字コード以外の数値リテ...
...//emlist{
puts
`ruby -h`
#=> Usage: ruby [switches] [--] [programfile] [arguments]
#=> ....
//}

===[a:backslash] \
バックスラッシュ。環境によって¥に見えたりします。

: puts "abc\"def"

文字列や正規表現の中のエスケープ。
//emlist{
puts
"abc\"de...

クラス/メソッドの定義 (358.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
//}

メソッド名...
...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) #=...
...t, x, y, z, k: 1, **kwrest, &blk)
puts
"a: %p" % a
puts
"b: %p" % b
puts
"c: %p" % c
puts
"m: %p" % m
puts
"n: %p" % n
puts
"rest: %p" % [rest]
puts
"x: %p" % x
puts
"y: %p" % y
puts
"z: %p" % z
puts
"k: %p" % k
puts
"kwrest: %p" % kwrest
puts
"blk: %p" % blk
end

f("a", "b",...

絞り込み条件を変える

制御構造 (288.0)

制御構造 条件分岐: * if * unless * case 繰り返し: * while * until * for * break * next * redo * retry 例外処理: * raise * begin その他: * return * BEGIN * END

...ない最初の
式を評価します。

//emlist[][ruby]{
foo = false
bar = true
quu = false

case
when foo then puts 'foo is true'
when bar then puts 'bar is true'
when quu then puts 'quu is true'
end
# "bar is true"と表示される
//}

case は、条件が成立した when 節、(あるいは...
...、これにより例外を処理することが
できます。

==== rescue修飾子

//emlist[例][ruby]{
open("nonexistent file") rescue STDERR.puts "Warning: #$!"
//}

文法:

式1 rescue 式2

式1で例外が発生したとき、式2を評価します。
以下と同じ意味です...

パターンマッチ (164.0)

パターンマッチ * patterns * variable_binding * variable_pinning * matching_non_primitive_objects * guard_clauses * current_feature_status * pattern_syntax * some_undefined_behavior_examples

...r:} # ネストしてハッシュにマッチして、その値を変数userに代入する
puts
"Connect with user '#{user}'"
in connection: {username: }
puts
"Connect with user '#{username}'"
else
puts
"Unrecognized structure of config"
end
# "Connect with user 'admin'" と出力
//}

一方...
...n', password: 'abc123'}}

config in {db: {user:}} # もし config の構造が期待したものでなかった場合には、例外が発生する

puts
"Connect with user '#{user}'"
# Connect with user 'admin'" と出力
//}

『<expression> in <pattern>』 は 『<expression>; in <pattern>; true;...
...ます。

//emlist[][ruby]{
class Point
def initialize(x, y)
@x, @y = x, y
end

def deconstruct
puts
"deconstruct called"
[@x, @y]
end

def deconstruct_keys(keys)
puts
"deconstruct_keys called with #{keys.inspect}"
{x: @x, y: @y}
end
end

case Point.new(1, -2)
in px,...
...n', password: 'abc123'}}

config => {db: {user:}} # もし config の構造が期待したものでなかった場合には、例外が発生する

puts
"Connect with user '#{user}'"
# Connect with user 'admin'" と出力
//}

『<expression> in <pattern>』 は 『<expression>; in <pattern>; true;...

Dir.mktmpdir(prefix_suffix = nil, tmpdir = nil) -> String (142.0)

一時ディレクトリを作成します。

...ィレクトリのパスを
返します。この場合、このメソッドは作成した一時ディレクトリを削除しません。

@param prefix_suffix nil の場合は、'd' をデフォルトのプレフィクスとして使用します。サフィックスは付きません。...
...ディレクトリを使用します。


使用例
require 'tmpdir'

puts
Dir.tmpdir
# 出力例: 動作環境により出力は異なります。
#=> /cygdrive/c/DOCUME~1/kouya/LOCALS~1/Temp
Dir.mktmpdir{|dir|
puts
dir
# 出力例: 一時ディレクトリ の名前の先頭に'...
...ir|
puts
dir
# 出力例:一時ディレクトリ の名前の先頭に'foo' をつける。
#=> /cygdrive/c/DOCUME~1/kouya/LOCALS~1/Temp/foo20081011-4824-pjvhwx
# ^^^
}
Dir.mktmpdir(["foo", "bar"]){|dir|
puts
di...

Dir.mktmpdir(prefix_suffix = nil, tmpdir = nil) {|dir| ... } -> object (142.0)

一時ディレクトリを作成します。

...ィレクトリのパスを
返します。この場合、このメソッドは作成した一時ディレクトリを削除しません。

@param prefix_suffix nil の場合は、'd' をデフォルトのプレフィクスとして使用します。サフィックスは付きません。...
...ディレクトリを使用します。


使用例
require 'tmpdir'

puts
Dir.tmpdir
# 出力例: 動作環境により出力は異なります。
#=> /cygdrive/c/DOCUME~1/kouya/LOCALS~1/Temp
Dir.mktmpdir{|dir|
puts
dir
# 出力例: 一時ディレクトリ の名前の先頭に'...
...ir|
puts
dir
# 出力例:一時ディレクトリ の名前の先頭に'foo' をつける。
#=> /cygdrive/c/DOCUME~1/kouya/LOCALS~1/Temp/foo20081011-4824-pjvhwx
# ^^^
}
Dir.mktmpdir(["foo", "bar"]){|dir|
puts
di...
<< 1 2 3 ... > >>