html-table 1.6.0 → 1.6.1

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.
@@ -1,120 +0,0 @@
1
- module HtmlHandler
2
-
3
- $upper = false
4
-
5
- # Used on HTML attributes. It creates proper HTML text based on the argument
6
- # type. A string looks like "attr='text'", a number looks like "attr=1",
7
- # while a true value simply looks like "attr" (no equal sign).
8
- #--
9
- # This is private method.
10
- #
11
- def modify_html(attribute,arg=nil)
12
- if @html_begin.scan(/\b#{attribute}\b/).empty?
13
- if arg.kind_of?(Integer)
14
- @html_begin << " #{attribute}=#{arg}"
15
- elsif arg.kind_of?(TrueClass)
16
- @html_begin << " #{attribute}"
17
- else
18
- @html_begin << " #{attribute}='#{arg}'"
19
- end
20
- else
21
- if arg.kind_of?(Integer)
22
- @html_begin.gsub!(/#{attribute}=\d+/,"#{attribute}=#{arg}")
23
- elsif arg.kind_of?(FalseClass)
24
- @html_begin.gsub!(/#{attribute}/,'')
25
- else
26
- @html_begin.gsub!(/#{attribute}=['\w\.]+/,"#{attribute}='#{arg}'")
27
- end
28
- end
29
- end
30
-
31
- # Returns the HTML text for the current object. Indentation and end tag
32
- # options are optional, based on the settings of the classes themselves.
33
- #
34
- # If +formatting+ is false, then formatting and whitespace is not applied
35
- # and you will get a single, very long string. Note that case is still
36
- # honored.
37
- #
38
- def html(formatting = true)
39
- if self.class.respond_to?(:html_case)
40
- $upper = true if self.class.html_case == "upper"
41
- end
42
-
43
- if $upper
44
- @html_begin.upcase!
45
- @html_end.upcase!
46
- end
47
-
48
- ilevel = 0
49
-
50
- if formatting && self.class.respond_to?(:indent_level)
51
- ilevel = self.class.indent_level
52
- end
53
-
54
- html = ' ' * ilevel + @html_begin[0..-1]
55
- len = html.length
56
- html[len,len] = '>'
57
-
58
- if self.kind_of?(Array)
59
- if formatting
60
- html << self.map{ |e| "\n" + e.html(formatting).to_s }.join
61
- else
62
- html << self.map{ |e| e.html(formatting).to_s }.join
63
- end
64
- else
65
- html << @html_body
66
- end
67
-
68
- #####################################################################
69
- # Add end tags, or not, depending on whether the class supports the
70
- # end_tags class method. Those that don't have an end_tags class
71
- # method necessarily means that the end tag must be included.
72
- #
73
- # The Table.global_end_tags method overrides the individual class
74
- # preferences with regards to end tags.
75
- #####################################################################
76
- if self.kind_of?(Array)
77
- if HTML::Table.global_end_tags?
78
- if self.class.respond_to?(:end_tags?)
79
- if formatting
80
- if self.class.end_tags?
81
- html << "\n" + (' ' * ilevel) + @html_end
82
- end
83
- else
84
- html << (' ' * ilevel) + @html_end if self.class.end_tags?
85
- end
86
- else
87
- if formatting
88
- html << "\n" + (' ' * ilevel) + @html_end
89
- else
90
- html << (' ' * ilevel) + @html_end
91
- end
92
- end
93
- else
94
- unless self.class.respond_to?(:end_tags?)
95
- if formatting
96
- html << "\n" + (' ' * ilevel) + @html_end
97
- else
98
- html << (' ' * ilevel) + @html_end
99
- end
100
- end
101
- end
102
- else
103
- if HTML::Table.global_end_tags?
104
- if self.class.respond_to?(:end_tags?)
105
- html << @html_end if self.class.end_tags?
106
- else
107
- html << @html_end
108
- end
109
- else
110
- unless self.class.respond_to?(:end_tags?)
111
- html << @html_end
112
- end
113
- end
114
- end
115
-
116
- return html
117
- end
118
-
119
- private :modify_html
120
- end
@@ -1,121 +0,0 @@
1
- ###################################################################
2
- # tag_handler.rb
3
- #
4
- # Module for handling standard html physical tags (<b>, <i>, etc).
5
- # Only used for Table::Content objects, which are in turn used by
6
- # Table::Row::Data, Table::Row::Header and Table::Caption.
7
- ###################################################################
8
- module TagHandler
9
- def bold(bool = nil)
10
- @bold ||= nil
11
- self.bold = bool if bool
12
- @bold
13
- end
14
-
15
- def bold=(bool)
16
- handle_physical_tag('b', bool)
17
- @bold = bool
18
- end
19
-
20
- def big(bool = nil)
21
- @big ||= nil
22
- self.big = bool if bool
23
- @big
24
- end
25
-
26
- def big=(bool)
27
- handle_physical_tag('big', bool)
28
- @big = bool
29
- end
30
-
31
- def blink(bool = nil)
32
- @blink ||= nil
33
- self.blink = bool if bool
34
- @blink
35
- end
36
-
37
- def blink=(bool)
38
- warn BlinkWarning, "The 'blink' tag is very annoying. Please reconsider."
39
- handle_physical_tag('blink', bool)
40
- @blink = bool
41
- end
42
-
43
- def italic(bool = nil)
44
- @italic ||= nil
45
- self.italic = bool if bool
46
- @italic
47
- end
48
-
49
- def italic=(bool)
50
- handle_physical_tag('i', bool)
51
- @italic = bool
52
- end
53
-
54
- def strike(bool = nil)
55
- @strike ||= nil
56
- self.strike = bool if bool
57
- @strike
58
- end
59
-
60
- def strike=(bool)
61
- handle_physical_tag('strike', bool)
62
- @strike = bool
63
- end
64
-
65
- def sub(bool = nil)
66
- @sub ||= nil
67
- self.sub = bool if bool
68
- @sub
69
- end
70
-
71
- def sub=(bool)
72
- handle_physical_tag('sub', bool)
73
- @sub = bool
74
- end
75
-
76
- def sup(bool = nil)
77
- @sup ||= nil
78
- self.sup = bool if bool
79
- @sup
80
- end
81
-
82
- def sup=(bool)
83
- handle_physical_tag('sup', bool)
84
- @sup = bool
85
- end
86
-
87
- def tt(bool = nil)
88
- @tt ||= nil
89
- self.tt = bool if bool
90
- @tt
91
- end
92
-
93
- def tt=(bool)
94
- handle_physical_tag('tt', bool)
95
- @tt = bool
96
- end
97
-
98
- def underline(bool = nil)
99
- @underline ||= nil
100
- self.underline = bool if bool
101
- @underline
102
- end
103
-
104
- def underline=(bool)
105
- handle_physical_tag('u', bool)
106
- @bool = bool
107
- end
108
-
109
- private
110
-
111
- def handle_physical_tag(tag, bool)
112
- begin_tag = "<#{tag}>"
113
- end_tag = "</#{tag}>"
114
-
115
- if bool
116
- self.replace(begin_tag << self << end_tag)
117
- else
118
- self.replace(self.gsub(/#{begin_tag}|#{end_tag}/,''))
119
- end
120
- end
121
- end
data/lib/strongtyping.rb DELETED
@@ -1,13 +0,0 @@
1
- # A pure-ruby replacement for strongtyping gem
2
-
3
- module StrongTyping
4
- class ArgumentTypeError < ArgumentError; end
5
-
6
- def expect(arg, allowed_types)
7
- return true if Array(allowed_types).any? do |klass|
8
- arg.kind_of?(klass)
9
- end
10
-
11
- raise ArgumentTypeError.new("#{arg} must be of type #{allowed_types}")
12
- end
13
- end