76件ヒット
[1-76件を表示]
(0.082秒)
クラス
- BasicObject (24)
-
Fiddle
:: Function (12) - Logger (12)
- Method (14)
- Proc (14)
キーワード
- << (14)
- >> (14)
- formatter (12)
-
instance
_ eval (24)
検索結果
先頭5件
-
Fiddle
:: Function # call(*args) -> Integer|DL :: CPtr|nil (18108.0) -
関数を呼び出します。
...いる C ポインタに変換されます。
文字列であればその先頭ポインタになります。
IO オブジェクトであれば FILE* が渡されます。
整数であればそれがアドレスとみなされます。
to_ptr を持っているならば、それを呼びだ... -
Method
# <<(callable) -> Proc (143.0) -
self と引数を合成した Proc を返します。
...まず受け取った引数を callable に渡して呼び出し、
その戻り値を self に渡して呼び出した結果を返します。
Method#>> とは呼び出しの順序が逆になります。
@param callable Proc、Method、もしくは任意の call メソッドを持ったオブジ......< method(:g)).call(3) # => 36
//}
//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT
pipeline = method(:pp) << WordScanner << File.method(:read......)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}
@see Proc#<<, Proc#>>... -
Method
# >>(callable) -> Proc (143.0) -
self と引数を合成した Proc を返します。
...数を self に渡して呼び出し、
その戻り値を callable に渡して呼び出した結果を返します。
Method#<< とは呼び出しの順序が逆になります。
@param callable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。
//emlist[......p (method(:f) >> method(:g)).call(3) # => 18
//}
//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT
pipeline = File.method(:read) >> WordScanne......r >> method(:pp)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}
@see Proc#<<, Proc#>>... -
Proc
# <<(callable) -> Proc (143.0) -
self と引数を合成した Proc を返します。
...、まず受け取った引数を callable に渡して呼び出し、
その戻り値を self に渡して呼び出した結果を返します。
Proc#>> とは呼び出しの順序が逆になります。
@param callable Proc、Method、もしくは任意の call メソッドを持ったオブ......* x }
g = proc { |x| x + x }
# (3 + 3) * (3 + 3)
p (f << g).call(3) # => 36
//}
//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT
pipeline =......proc { |data| puts "word count: #{data.size}" } << WordScanner << File.method(:read)
pipeline.call('testfile') # => word count: 4
//}
@see Method#<<, Method#>>... -
Proc
# >>(callable) -> Proc (143.0) -
self と引数を合成した Proc を返します。
...数を self に渡して呼び出し、
その戻り値を callable に渡して呼び出した結果を返します。
Proc#<< とは呼び出しの順序が逆になります。
@param callable Proc、Method、もしくは任意の call メソッドを持ったオブジェクト。
//emlist[例......+ (3 * 3)
p (f >> g).call(3) # => 18
//}
//emlist[call を定義したオブジェクトを渡す例][ruby]{
class WordScanner
def self.call(str)
str.scan(/\w+/)
end
end
File.write('testfile', <<~TEXT)
Hello, World!
Hello, Ruby!
TEXT
pipeline = proc { |fname| File.read(fname) } >> Wor......dScanner >> method(:p)
pipeline.call('testfile') # => ["Hello", "World", "Hello", "Ruby"]
//}
@see Method#<<, Method#>>... -
BasicObject
# instance _ eval(expr , filename = "(eval)" , lineno = 1) -> object (137.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
...レベルの定数が Object 以下に作成されるためです。
@param expr 評価する文字列です。
@param filename 文字列を指定します。ファイル filename に文字列 expr が
書かれているかのように実行されます。スタックトレース......ance_eval 'raise messg','file.rb',999 # file.rb:999: unknown (RuntimeError)
//}
//emlist[例][ruby]{
class Bar < BasicObject
def call1
instance_eval("::ENV.class")
end
def call2
instance_eval("ENV.class")
end
end
bar = Bar.new
bar.call1 # => Object
bar.call2 # raise NameError
//}... -
BasicObject
# instance _ eval {|obj| . . . } -> object (37.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
...レベルの定数が Object 以下に作成されるためです。
@param expr 評価する文字列です。
@param filename 文字列を指定します。ファイル filename に文字列 expr が
書かれているかのように実行されます。スタックトレース......ance_eval 'raise messg','file.rb',999 # file.rb:999: unknown (RuntimeError)
//}
//emlist[例][ruby]{
class Bar < BasicObject
def call1
instance_eval("::ENV.class")
end
def call2
instance_eval("ENV.class")
end
end
bar = Bar.new
bar.call1 # => Object
bar.call2 # raise NameError
//}... -
Logger
# formatter -> String (13.0) -
ログを出力する際に使用するフォーマッターを取得します。
...ログを出力する際に使用するフォーマッターを取得します。
このメソッドの返り値が持つ call メソッドは 4 つの引数 (severity, time, program name, message) を受けとります。
//emlist[例][ruby]{
require 'logger'
logger = Logger.new(STDOUT)
logger.......g|
"time:#{timestamp}\tlevel:#{severity}\tprogname:#{progname}\tmessage:#{msg}\n"
}
logger.formatter = ltsv_formatter
logger.formatter # => #<Proc:0x00007fa3048b8e00@/path/to/file:8>
logger.info("MyApp") { "test" }
# => time:2019-05-09 22:13:56 +0900 level:INFO progname:MyApp message:test
//}...