Class: HOM::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/hom.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, attributes = nil, content = Undefined) ⇒ Element

Returns a new instance of Element.



33
34
35
# File 'lib/hom.rb', line 33

def initialize(tag_name, attributes = nil, content = Undefined)
  @tag_name, @attributes, @content = tag_name, AttributeList.new.update(attributes), content
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



31
32
33
# File 'lib/hom.rb', line 31

def attributes
  @attributes
end

#contentObject (readonly)

Returns the value of attribute content.



31
32
33
# File 'lib/hom.rb', line 31

def content
  @content
end

#tag_nameObject (readonly)

Returns the value of attribute tag_name.



31
32
33
# File 'lib/hom.rb', line 31

def tag_name
  @tag_name
end

Instance Method Details

#content?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/hom.rb', line 37

def content?
  @content != Undefined
end

#html_safe?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/hom.rb', line 41

def html_safe?
  true
end

#to_sObject



45
46
47
# File 'lib/hom.rb', line 45

def to_s
  Encoding.safe_encode(self)
end