Class: Document
Instance Attribute Summary collapse
Attributes inherited from Element
#attributes, #elements
Instance Method Summary
collapse
Methods inherited from Element
#add_attribute, #add_elements, #render, #rendered_attributes, #rendered_elements, #tag
Constructor Details
#initialize(*elements, header_elements: []) ⇒ Document
Returns a new instance of Document.
4
5
6
7
|
# File 'lib/ruby_html/elements/document.rb', line 4
def initialize(*elements, header_elements: [])
@elements = elements
@header_elements = .flatten
end
|
Instance Attribute Details
Returns the value of attribute header_elements.
2
3
4
|
# File 'lib/ruby_html/elements/document.rb', line 2
def
@header_elements
end
|
Instance Method Details
#closing_tag ⇒ Object
19
20
21
|
# File 'lib/ruby_html/elements/document.rb', line 19
def closing_tag
"</body></html>"
end
|
#opening_tag ⇒ Object
9
10
11
|
# File 'lib/ruby_html/elements/document.rb', line 9
def opening_tag
"<!DOCTYPE><html><head>#{}</head><body>"
end
|
#render_to_file(path) ⇒ Object
23
24
25
|
# File 'lib/ruby_html/elements/document.rb', line 23
def render_to_file(path)
File.open(path, "w") { |file| file.write(render) }
end
|
13
14
15
16
17
|
# File 'lib/ruby_html/elements/document.rb', line 13
def
.map do |element|
element.render
end.join("")
end
|