72件ヒット
[1-72件を表示]
(0.018秒)
別のキーワード
種類
- インスタンスメソッド (48)
- 定数 (12)
- 特異メソッド (12)
検索結果
先頭5件
-
Object
:: DATA -> File (19.0) -
スクリプトの __END__ プログラムの終り以降をアクセスする File オブジェクト。
...あったとします。
library.rb:
print DATA.gets
__END__
data from library
app.rb:
require 'library.rb'
__END__
data from app
このときシェルから次を実行すると
$ ruby app.rb
結果は以下のように出力されます。
data from app... -
Object
# enum _ for(method = :each , *args) -> Enumerator (7.0) -
Enumerator.new(self, method, *args) を返します。
...す。
//emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enu... -
Object
# enum _ for(method = :each , *args) {|*args| . . . } -> Enumerator (7.0) -
Enumerator.new(self, method, *args) を返します。
...す。
//emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enu... -
Object
# to _ enum(method = :each , *args) -> Enumerator (7.0) -
Enumerator.new(self, method, *args) を返します。
...す。
//emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enu... -
Object
# to _ enum(method = :each , *args) {|*args| . . . } -> Enumerator (7.0) -
Enumerator.new(self, method, *args) を返します。
...す。
//emlist[][ruby]{
str = "xyz"
enum = str.enum_for(:each_byte)
p(a = enum.map{|b| '%02x' % b }) #=> ["78", "79", "7a"]
# protects an array from being modified
a = [1, 2, 3]
p(a.to_enum) #=> #<Enumerator: [1, 2, 3]:each>
//}
//emlist[例(ブロックを指定する場合)][ruby]{
module Enu... -
Object
. yaml _ tag(tag) -> () (7.0) -
クラスと tag の間を関連付けます。
...end
attr_reader :x
end
# Dumps Ruby object normally
p Psych.dump(Foo.new(3))
# =>
# --- !ruby/object:Foo
# x: 3
# Registers tag with class Foo
Foo.yaml_as("tag:example.com,2013:foo")
# ... and dumps the object of Foo class
Psych.dump(Foo.new(3), STDOUT)
# =>......# --- !<tag:example.com,2013:foo>
# x: 3
# Loads the object from the tagged YAML node
p Psych.load(<<EOS)
--- !<tag:example.com,2012:foo>
x: 8
EOS
# => #<Foo:0x0000000130f48 @x=8>...