60件ヒット
[1-60件を表示]
(0.058秒)
別のキーワード
ライブラリ
- erb (60)
キーワード
-
def
_ class (12) -
def
_ method (12) -
def
_ module (12) - result (12)
- run (12)
検索結果
先頭5件
-
ERB
# def _ class(superklass=Object , methodname=& # 39;erb& # 39;) -> Class (36.0) -
変換した Ruby スクリプトをメソッドとして定義した無名のクラスを返します。
...変換した Ruby スクリプトをメソッドとして定義した無名のクラスを返します。
@param superklass 無名クラスのスーパークラス
@param methodname メソッド名
//emlist[例][ruby]{
require 'erb'
class MyClass_
def initialize(arg1, 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
# test2123
//}... -
ERB
# def _ method(mod , methodname , fname=& # 39;(ERB)& # 39;) -> nil (36.0) -
変換した Ruby スクリプトをメソッドとして定義します。
...換した Ruby スクリプトをメソッドとして定義します。
定義先のモジュールは mod で指定し、メソッド名は methodname で指定します。
fname はスクリプトを定義する際のファイル名です。主にエラー時に活躍します。
@param mod メ......ソッドを定義するモジュール(またはクラス)
@param methodname メソッド名
@param fname スクリプトを定義する際のファイル名
例:
require 'erb'
erb = ERB.new(script)
erb.def_method(MyClass, 'foo(bar)', 'foo.erb')... -
ERB
# def _ module(methodname=& # 39;erb& # 39;) -> Module (30.0) -
変換した Ruby スクリプトをメソッドとして定義した無名のモジュールを返します。
...た Ruby スクリプトをメソッドとして定義した無名のモジュールを返します。
@param methodname メソッド名
//emlist[例][ruby]{
require 'erb'
filename = 'example.rhtml'
erb = ERB.new("test1<%= arg1 %>\ntest2<%= arg2 %>\n")
erb.filename = filename
MyModule = erb.def_mo... -
ERB
# result(b=TOPLEVEL _ BINDING) -> String (14.0) -
ERB を b の binding で実行し、結果の文字列を返します。
...
ERB を b の binding で実行し、結果の文字列を返します。
@param b eRubyスクリプトが実行されるときのbinding
//emlist[例][ruby]{
require 'erb'
erb = ERB.new("test <%= test1 %>\ntest <%= test2 %>\n")
test1 = "foo"
test2 = "bar"
puts erb.result
# test foo
# test bar
//......}
@see ERB#result_with_hash... -
ERB
# run(b=TOPLEVEL _ BINDING) -> nil (14.0) -
ERB を b の binding で実行し、結果を標準出力へ印字します。
...
ERB を b の binding で実行し、結果を標準出力へ印字します。
@param b eRubyスクリプトが実行されるときのbinding
//emlist[例][ruby]{
require 'erb'
erb = ERB.new("test <%= test1 %>\ntest <%= test2 %>\n")
test1 = "foo"
test2 = "bar"
erb.run
# test foo
# test bar
//}...