Class: PinkShirt::SAX::Lists
- Inherits:
-
Base
- Object
- Base
- PinkShirt::SAX::Lists
show all
- Defined in:
- lib/pink_shirt/sax/lists.rb
Constant Summary
collapse
- TAGS =
%w(ul ol li dl dt dd)
Instance Method Summary
collapse
Methods inherited from Base
#add_attributes, #method_missing, #to_s
Constructor Details
#initialize(*args) ⇒ Lists
Returns a new instance of Lists.
5
6
7
8
9
|
# File 'lib/pink_shirt/sax/lists.rb', line 5
def initialize(*args)
@last_depth = 0
@nesting = []
super
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class PinkShirt::SAX::Base
Instance Method Details
#end_dd ⇒ Object
65
66
67
|
# File 'lib/pink_shirt/sax/lists.rb', line 65
def end_dd
@output << "\n"
end
|
#end_dl ⇒ Object
51
52
|
# File 'lib/pink_shirt/sax/lists.rb', line 51
def end_dl
end
|
#end_dt ⇒ Object
58
59
|
# File 'lib/pink_shirt/sax/lists.rb', line 58
def end_dt
end
|
#end_li ⇒ Object
43
44
45
46
|
# File 'lib/pink_shirt/sax/lists.rb', line 43
def end_li
@output << "\n" unless @last_depth > @nesting.length
@last_depth = @nesting.length
end
|
#end_ol ⇒ Object
28
29
30
31
|
# File 'lib/pink_shirt/sax/lists.rb', line 28
def end_ol
@nesting.pop
@in_ol = false
end
|
#end_ul ⇒ Object
17
18
19
20
|
# File 'lib/pink_shirt/sax/lists.rb', line 17
def end_ul
@nesting.pop
@in_ul = false
end
|
#start_dd(attrs) ⇒ Object
61
62
63
|
# File 'lib/pink_shirt/sax/lists.rb', line 61
def start_dd attrs
@output << " := "
end
|
#start_dl(attrs) ⇒ Object
48
49
|
# File 'lib/pink_shirt/sax/lists.rb', line 48
def start_dl attrs
end
|
#start_dt(attrs) ⇒ Object
54
55
56
|
# File 'lib/pink_shirt/sax/lists.rb', line 54
def start_dt attrs
@output << "- "
end
|
#start_li(attrs) ⇒ Object
33
34
35
36
37
38
39
40
41
|
# File 'lib/pink_shirt/sax/lists.rb', line 33
def start_li(attrs)
current_nest = @nesting.last
if current_nest == "ol"
chr = "#"
else
chr = "*"
end
@output << Array.new(@nesting.length).map{chr}.join + " "
end
|
#start_ol(attrs) ⇒ Object
22
23
24
25
26
|
# File 'lib/pink_shirt/sax/lists.rb', line 22
def start_ol(attrs)
@nesting.push('ol')
@in_ol = true
@output << "\n" unless @nesting.length == 1
end
|
#start_ul(attrs) ⇒ Object
11
12
13
14
15
|
# File 'lib/pink_shirt/sax/lists.rb', line 11
def start_ul(attrs)
@nesting.push "ul"
@in_ul = true
@output << "\n" unless @nesting.length == 1
end
|