rbhtml 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rbhtml.rb +41 -31
- metadata +4 -3
data/lib/rbhtml.rb
CHANGED
@@ -1,35 +1,45 @@
|
|
1
1
|
class String
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
def strpush! push
|
3
|
+
newstring = push + self
|
4
|
+
self.replace(newstring)
|
5
|
+
end
|
6
6
|
end
|
7
7
|
class HTMLDocument
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
8
|
+
private
|
9
|
+
def refresh_full
|
10
|
+
@full_doc = @open_doc + @close_doc
|
11
|
+
end
|
12
|
+
def index_element tag, inner
|
13
|
+
@index_dict["#{tag}///#{@index_id}"] = "#{inner}"
|
14
|
+
end
|
15
|
+
public
|
16
|
+
def initialize
|
17
|
+
@open_doc = "<html><body>"
|
18
|
+
@close_doc = "</body></html>"
|
19
|
+
@full_doc = @open_doc + @close_doc
|
20
|
+
@index_dict = {}
|
21
|
+
@index_id = 0
|
22
|
+
end
|
23
|
+
def create_element tag, inner, attribute=false, value=false
|
24
|
+
if attribute and value
|
25
|
+
@open_doc += "<#{tag} #{attribute}='#{value}'>#{inner}</#{tag}>"
|
26
|
+
else
|
27
|
+
@open_doc += "<#{tag}>#{inner}</#{tag}>"
|
27
28
|
end
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
29
|
+
@index_id += 1
|
30
|
+
refresh_full
|
31
|
+
index_element tag, inner
|
32
|
+
end
|
33
|
+
def remove_element tag, inner
|
34
|
+
@open_doc.gsub!("<#{tag}>#{inner}", "")
|
35
|
+
@close_doc.gsub!("</#{tag}>", "")
|
36
|
+
refresh_full
|
37
|
+
end
|
38
|
+
def remove_char char
|
39
|
+
@open_doc.gsub!(">#{char}", ">")
|
40
|
+
refresh_full
|
41
|
+
end
|
42
|
+
def to_s
|
43
|
+
@full_doc
|
44
|
+
end
|
45
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbhtml
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,9 +9,10 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-03 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
|
-
description: An HTML generator written in Ruby
|
14
|
+
description: An HTML generator written in Ruby. Added attributes to create_element
|
15
|
+
method. Removed bug where if you create two elements, the elements overlap.
|
15
16
|
email: slmnwise@gmail.com
|
16
17
|
executables: []
|
17
18
|
extensions: []
|