るりまサーチ (Ruby 2.4.0)

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

別のキーワード

  1. kernel test
  2. _builtin test
  3. rubygems/test_utilities tempio
  4. rubygems/test_utilities fetcher=
  5. testtask test_files=

クラス

キーワード

検索結果

ERB#result(b=TOPLEVEL_BINDING) -> String (136.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
//...

ERB#run(b=TOPLEVEL_BINDING) -> nil (136.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
//}...

ERB#def_module(methodname=&#39;erb&#39;) -> Module (64.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#def_class(superklass=Object, methodname=&#39;erb&#39;) -> Class (46.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#src -> String (46.0)

変換した 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); _erbout.<< "\n\n".freeze
#
# ; _erbout
//}...

絞り込み条件を変える