Class: HTMLDocument

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

Instance Method Summary collapse

Constructor Details

#initializeHTMLDocument

Returns a new instance of HTMLDocument.



13
14
15
16
17
# File 'lib/rbhtml.rb', line 13

def initialize
    @open_doc = "<html><body>"
    @close_doc = "</body></html>"
    @full_doc = @open_doc + @close_doc
end

Instance Method Details

#create_element(tag, inner) ⇒ Object



18
19
20
21
22
# File 'lib/rbhtml.rb', line 18

def create_element tag, inner
    @open_doc += "<#{tag}>#{inner}"
    @close_doc.strpush!("</#{tag}>")
    refresh_full
end

#remove_char(char) ⇒ Object



28
29
30
31
# File 'lib/rbhtml.rb', line 28

def remove_char char
    @open_doc.gsub!(">#{char}", ">")
    refresh_full
end

#remove_element(tag, inner) ⇒ Object



23
24
25
26
27
# File 'lib/rbhtml.rb', line 23

def remove_element tag, inner
    @open_doc.gsub!("<#{tag}>#{inner}", "")
    @close_doc.gsub!("</#{tag}>", "")
    refresh_full
end

#to_sObject



32
33
34
# File 'lib/rbhtml.rb', line 32

def to_s
    @full_doc
end