99件ヒット
[1-99件を表示]
(0.096秒)
ライブラリ
- ビルトイン (22)
- erb (44)
- optparse (11)
- rake (11)
-
webrick
/ httputils (11)
クラス
- BasicObject (22)
- ERB (44)
- OptionParser (11)
-
Rake
:: FileList (11) -
WEBrick
:: HTTPUtils :: FormData (11)
キーワード
-
def
_ class (11) -
def
_ module (11) - egrep (11)
- filename (11)
-
instance
_ eval (22) - load (11)
検索結果
先頭5件
-
ERB
# filename= -> String (18120.0) -
エラーメッセージを表示する際のファイル名を設定します。
...filename を設定していない場合は、エラー発生箇所は「 (ERB) 」という出力となります。
//emlist[例][ruby]{
require 'erb'
filename = 'example.rhtml'
erb = ERB.new(File.read(filename))
erb.filename # => nil
erb.filename = filename
erb.filename # =>"example.rhtml"
//}... -
WEBrick
:: HTTPUtils :: FormData # filename=(value) (15107.0) -
フォームデータの filename 属性を文字列で表すアクセサです。
...性を文字列で表すアクセサです。
@param value フォームデータの filename 属性を文字列で指定します。
例:
require "webrick/cgi"
class MyCGI < WEBrick::CGI
def do_GET(req, res)
p req.query['q'].filename #=> "my_file.txt"
end
end
MyCGI.new.start()... -
Rake
:: FileList # egrep(pattern) {|filename , count , line| . . . } (55.0) -
与えられたパターンをファイルリストから grep のように検索します。
...t.new('sample*')
file_list.egrep(/line/) # => 7
file_list.egrep(/.*/) do |filename, count, line|
"filename = #{filename}, count = #{count}, line = #{line}"
end
end
# => "filename = sample1, count = 1, line = line1\n"
# => "filename = sample1, count = 2, line = line2\n"
# => "filename = s......ample1, count = 3, line = line3\n"
# => "filename = sample2, count = 1, line = line1\n"
# => "filename = sample2, count = 2, line = line2\n"
# => "filename = sample2, count = 3, line = line3\n"
# => "filename = sample2, count = 4, line = line4\n"
//}... -
ERB
# def _ class(superklass=Object , methodname=& # 39;erb& # 39;) -> Class (25.0) -
変換した Ruby スクリプトをメソッドとして定義した無名のクラスを返します。
...arg2)
@arg1 = arg1; @arg2 = arg2
end
end
filename = 'example.rhtml' # @arg1 と @arg2 が使われている example.rhtml
erb = ERB.new(File.read(filename))
erb.filename = filename
MyClass = erb.def_class(MyClass_, 'render()')
print MyClass.new('foo', 123).render()
# => test1foo
# test2... -
ERB
# def _ module(methodname=& # 39;erb& # 39;) -> Module (25.0) -
変換した Ruby スクリプトをメソッドとして定義した無名のモジュールを返します。
...ッド名
//emlist[例][ruby]{
require 'erb'
filename = 'example.rhtml'
erb = ERB.new("test1<%= arg1 %>\ntest2<%= arg2 %>\n")
erb.filename = filename
MyModule = erb.def_module('render(arg1, arg2)')
class MyClass
include MyModule
end
print MyClass.new.render('foo', 123)
# test1foo
# test2123
//}... -
ERB
# filename -> String (19.0) -
エラーメッセージを表示する際のファイル名を取得します。
...エラーメッセージを表示する際のファイル名を取得します。
//emlist[例][ruby]{
require 'erb'
filename = 'example.rhtml'
erb = ERB.new(File.read(filename))
erb.filename # => nil
erb.filename = filename
erb.filename # =>"example.rhtml"
//}... -
BasicObject
# instance _ eval {|obj| . . . } -> object (14.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
...ます。
//emlist[例][ruby]{
class Foo
def initialize data
@key = data
end
private
def do_fuga
p 'secret'
end
end
some = Foo.new 'XXX'
some.instance_eval{p @key} #=> "XXX"
some.instance_eval{do_fuga } #=> "secret" # private メソッドも呼び出せる
some.instance_eval 'ra......imeError)
//}
//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
//}
@see Module#module_eval, Kernel.#eval, BasicObject#instance_exec... -
BasicObject
# instance _ eval(expr , filename = "(eval)" , lineno = 1) -> object (14.0) -
オブジェクトのコンテキストで文字列 expr またはオブジェクト自身をブロックパラメータとするブロックを 評価してその結果を返します。
...ます。
//emlist[例][ruby]{
class Foo
def initialize data
@key = data
end
private
def do_fuga
p 'secret'
end
end
some = Foo.new 'XXX'
some.instance_eval{p @key} #=> "XXX"
some.instance_eval{do_fuga } #=> "secret" # private メソッドも呼び出せる
some.instance_eval 'ra......imeError)
//}
//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
//}
@see Module#module_eval, Kernel.#eval, BasicObject#instance_exec... -
OptionParser
# load(filename = nil) -> bool (8.0) -
指定された filename を読み込んで各行をまとめたものに対して OptionParser#parse を行ないます。
...します。
//emlist[例][ruby]{
require "optparse"
IO.write("options.txt", %w(-a --b).join("\n"))
options = { a: false, b: false }
OptionParser.new do |opt|
opt.on('-a') { |v| options[:a] = v }
opt.on('--b') {|v| options[:b] = v }
opt.load("options.txt") # => true
opt.load("not_exist.t...