Class: Erubi::CaptureBlockEngine::Buffer
- Inherits:
-
String
- Object
- String
- Erubi::CaptureBlockEngine::Buffer
- Defined in:
- lib/erubi/capture_block.rb
Instance Method Summary collapse
-
#<<(v) ⇒ Object
Convert argument to string when concatening.
-
#capture(*args) ⇒ Object
Temporarily clear the receiver before yielding to the block, yield the given args to the block, return any data captured by the receiver, and restore the original data the receiver contained before returning.
-
#|(v) ⇒ Object
Escape argument using Erubi.h then then concatenate it to the receiver.
Instance Method Details
#<<(v) ⇒ Object
Convert argument to string when concatening
35 36 37 |
# File 'lib/erubi/capture_block.rb', line 35 def <<(v) concat(v.to_s) end |
#capture(*args) ⇒ Object
Temporarily clear the receiver before yielding to the block, yield the given args to the block, return any data captured by the receiver, and restore the original data the receiver contained before returning.
47 48 49 50 51 52 53 54 |
# File 'lib/erubi/capture_block.rb', line 47 def capture(*args) prev = dup replace("") # 1.8 support! yield(*args) dup ensure replace(prev) end |
#|(v) ⇒ Object
Escape argument using Erubi.h then then concatenate it to the receiver.
40 41 42 |
# File 'lib/erubi/capture_block.rb', line 40 def |(v) concat(h(v)) end |