4件ヒット
[1-4件を表示]
(0.020秒)
種類
- インスタンスメソッド (2)
- モジュール関数 (1)
- 特異メソッド (1)
クラス
- ERB (3)
モジュール
-
ERB
:: DefMethod (1)
キーワード
-
def
_ class (1) -
def
_ erb _ method (1) -
def
_ module (1) - new (1)
検索結果
先頭4件
-
ERB
# def _ class(superklass=Object , methodname=& # 39;erb& # 39;) -> Class (18649.0) -
変換した Ruby スクリプトをメソッドとして定義した無名のクラスを返します。
...mlist[例][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_, 'rend... -
ERB
. new(str , safe _ level=nil , trim _ mode=nil , eoutvar=& # 39; _ erbout& # 39;) -> ERB (43.0) -
eRubyスクリプト から ERB オブジェクトを生成して返します。
...eRubyスクリプト から ERB オブジェクトを生成して返します。
@param str eRubyスクリプトを表す文字列
@param safe_level eRubyスクリプトが実行されるときのセーフレベル
@param trim_mode 整形の挙動を変更するオプション
@param eoutvar eRuby......スクリプトの中で出力をためていく変数の名前を表す文
字列。eRuby スクリプトの中でさらに ERB を使うときに変更
します。通常は指定する必要はありません。
Ruby 2.6.0 から位置引数での safe_level, trim_m......3.2 で削除されました。
trim_mode と eoutvar の指定はキーワード引数に移行してください。
//emlist[例][ruby]{
require "erb"
# build data class
class Listings
PRODUCT = { :name => "Chicken Fried Steak",
:desc => "A well messages pattie, breaded and fried... -
ERB
# def _ module(methodname=& # 39;erb& # 39;) -> Module (25.0) -
変換した Ruby スクリプトをメソッドとして定義した無名のモジュールを返します。
...ルを返します。
@param methodname メソッド名
//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... -
ERB
:: DefMethod . # def _ erb _ method(methodname , erb) -> nil (25.0) -
self に erb のスクリプトをメソッドとして定義します。
... erb のスクリプトをメソッドとして定義します。
メソッド名は methodname で指定します。
erb が文字列の時、そのファイルを読み込み ERB で変換したのち、メソッドとして定義します。
@param methodname メソッド名
@param erb ERBイ......ンスタンスもしくはERBソースファイル名
例:
require 'erb'
class Writer
extend ERB::DefMethod
def_erb_method('to_html', 'writer.erb')
...
end
...
puts writer.to_html...