Class: HOM::Element
- Inherits:
-
Object
- Object
- HOM::Element
- Defined in:
- lib/hom.rb
Instance Attribute Summary collapse
-
#attributes ⇒ Object
readonly
Returns the value of attribute attributes.
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#tag_name ⇒ Object
readonly
Returns the value of attribute tag_name.
Instance Method Summary collapse
- #+(object) ⇒ Object
- #content? ⇒ Boolean
- #html_safe? ⇒ Boolean
-
#initialize(tag_name, attributes = nil, content = Undefined) ⇒ Element
constructor
A new instance of Element.
- #to_s ⇒ Object
Constructor Details
#initialize(tag_name, attributes = nil, content = Undefined) ⇒ Element
Returns a new instance of Element.
37 38 39 |
# File 'lib/hom.rb', line 37 def initialize(tag_name, attributes = nil, content = Undefined) @tag_name, @attributes, @content = tag_name, AttributeList.new.update(attributes), content end |
Instance Attribute Details
#attributes ⇒ Object (readonly)
Returns the value of attribute attributes.
35 36 37 |
# File 'lib/hom.rb', line 35 def attributes @attributes end |
#content ⇒ Object (readonly)
Returns the value of attribute content.
35 36 37 |
# File 'lib/hom.rb', line 35 def content @content end |
#tag_name ⇒ Object (readonly)
Returns the value of attribute tag_name.
35 36 37 |
# File 'lib/hom.rb', line 35 def tag_name @tag_name end |
Instance Method Details
#+(object) ⇒ Object
53 54 55 |
# File 'lib/hom.rb', line 53 def +(object) NodeList.new([self, object]) end |
#html_safe? ⇒ Boolean
45 46 47 |
# File 'lib/hom.rb', line 45 def html_safe? true end |
#to_s ⇒ Object
49 50 51 |
# File 'lib/hom.rb', line 49 def to_s Encoding.safe_encode(self) end |