Class: HTML::Fragment
- Inherits:
-
Object
- Object
- HTML::Fragment
- Includes:
- Adamantium
- Defined in:
- lib/html/fragment.rb
Overview
An html fragment
Constant Summary collapse
- EMPTY =
new('')
Instance Attribute Summary collapse
-
#content ⇒ String
(also: #to_s)
readonly
private
Return contents of fragment.
Class Method Summary collapse
-
.build(input) ⇒ Fragment
private
Create new fragment.
Instance Method Summary collapse
-
#each {|content| ... } ⇒ self
private
Enumerate contents.
-
#initialize(string) ⇒ undefined
constructor
private
Initialize object.
Constructor Details
#initialize(string) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize object
25 26 27 |
# File 'lib/html/fragment.rb', line 25 def initialize(string) @content = string end |
Instance Attribute Details
#content ⇒ String (readonly) Also known as: to_s
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return contents of fragment
15 16 17 |
# File 'lib/html/fragment.rb', line 15 def content @content end |
Class Method Details
.build(input) ⇒ Fragment
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create new fragment
60 61 62 63 64 65 66 |
# File 'lib/html/fragment.rb', line 60 def self.build(input) if input.kind_of?(self) input else new(HTML.escape(input)) end end |
Instance Method Details
#each {|content| ... } ⇒ self
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Enumerate contents
The idea is to make it compatible with a rack body.
46 47 48 49 50 |
# File 'lib/html/fragment.rb', line 46 def each return to_enum unless block_given? yield content self end |