るりまサーチ

最速Rubyリファレンスマニュアル検索!
72件ヒット [1-72件を表示] (0.148秒)

別のキーワード

  1. rbconfig ruby
  2. fiddle ruby_free
  3. fiddle build_ruby_platform
  4. rake ruby
  5. rubygems/defaults ruby_engine

ライブラリ

キーワード

検索結果

ERB#def_method(mod, methodname, fname='(ERB)') -> nil (6252.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#result(b=TOPLEVEL_BINDING) -> String (6126.0)

ERB を b の binding で実行し、結果の文字列を返します。

...
ERB
を b の binding で実行し、結果の文字列を返します。

@
param b eRubyスクリプトが実行されるときのbinding

//emlist[例][ruby]{
require 'erb'
erb
= ERB.new("test <%= test1 %>\ntest <%= test2 %>\n")
t
est1 = "foo"
t
est2 = "bar"
puts erb.result
# test foo
# test bar
//...
...}

@
see ERB#result_with_hash...

ERB#def_class(superklass=Object, methodname=&#39;erb&#39;) -> Class (182.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#src -> String (170.0)

変換した Ruby スクリプトを取得します。

... Ruby スクリプトを取得します。

//emlist[例][ruby]{
require 'erb'
erb
= ERB.new("test1<%= @arg1%>\ntest2<%= @arg2%>\n\n")
puts erb.src

# #coding:UTF-8
# _erbout = +''; _erbout.<< "test1".freeze; _erbout.<<(( @arg1).to_s); _erbout.<< "\ntest2".freeze
# ; _erbout.<<(( @arg2).to_s); _erbo...
...ut.<< "\n\n".freeze
#
# ; _erbout
//}...

ERB#def_module(methodname=&#39;erb&#39;) -> Module (152.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...
...dule('render(arg1, arg2)')
class MyClass
include MyModule
end
print MyClass.new.render('foo', 123)
# test1foo
# test2123
//}...

絞り込み条件を変える

ERB#run(b=TOPLEVEL_BINDING) -> nil (120.0)

ERB を b の binding で実行し、結果を標準出力へ印字します。

...
ERB
を b の binding で実行し、結果を標準出力へ印字します。

@
param b eRubyスクリプトが実行されるときのbinding

//emlist[例][ruby]{
require 'erb'
erb
= ERB.new("test <%= test1 %>\ntest <%= test2 %>\n")
t
est1 = "foo"
t
est2 = "bar"
erb
.run
# test foo
# test bar
//}...