html-table 1.3.3 → 1.3.4

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/html/body.rb CHANGED
@@ -1,38 +1,38 @@
1
- module HTML
2
-
3
- # This class represents an HTML table body (<tbody>). It is a
4
- # subclass of Table::TableSection.
5
- #
6
- class Table::Body < Table::TableSection
7
- @indent_level = 3
8
- @end_tags = true
9
-
10
- # Returns a new Table::Body object. Optionally takes a block. If
11
- # an argument is provided, it is treated as content.
12
- #
13
- def initialize(arg = nil, &block)
14
- @html_begin = "<tbody"
15
- @html_end = "</tbody>"
16
- instance_eval(&block) if block_given?
17
- self.content = arg if arg
18
- end
19
-
20
- # Returns a boolean indicating whether or not end tags, </tbody>, are
21
- # included for each Body object in the final HTML output. The
22
- # default is true.
23
- #
24
- def self.end_tags?
25
- @end_tags
26
- end
27
-
28
- # Sets whether or not end tags are included for each Body object in
29
- # the final HTML output. The default is true. Only true or false are
30
- # valid arguments.
31
- #
32
- def self.end_tags=(bool)
33
- expect(bool,[TrueClass,FalseClass])
34
- @end_tags = bool
35
- end
36
- end
37
-
38
- end
1
+ module HTML
2
+
3
+ # This class represents an HTML table body (<tbody>). It is a
4
+ # subclass of Table::TableSection.
5
+ #
6
+ class Table::Body < Table::TableSection
7
+ @indent_level = 3
8
+ @end_tags = true
9
+
10
+ # Returns a new Table::Body object. Optionally takes a block. If
11
+ # an argument is provided, it is treated as content.
12
+ #
13
+ def initialize(arg = nil, &block)
14
+ @html_begin = "<tbody"
15
+ @html_end = "</tbody>"
16
+ instance_eval(&block) if block_given?
17
+ self.content = arg if arg
18
+ end
19
+
20
+ # Returns a boolean indicating whether or not end tags, </tbody>, are
21
+ # included for each Body object in the final HTML output. The
22
+ # default is true.
23
+ #
24
+ def self.end_tags?
25
+ @end_tags
26
+ end
27
+
28
+ # Sets whether or not end tags are included for each Body object in
29
+ # the final HTML output. The default is true. Only true or false are
30
+ # valid arguments.
31
+ #
32
+ def self.end_tags=(bool)
33
+ expect(bool,[TrueClass,FalseClass])
34
+ @end_tags = bool
35
+ end
36
+ end
37
+
38
+ end
data/lib/html/caption.rb CHANGED
@@ -1,48 +1,48 @@
1
- module HTML
2
-
3
- # This class represents an HTML Caption. Despite the name, it is not
4
- # a subclass of Table. Note that end tags for this class are mandatory.
5
- #
6
- class Table::Caption
7
- include AttributeHandler
8
- include HtmlHandler
9
-
10
- undef_method :configure
11
- @indent_level = 3
12
-
13
- # Returns a new Table::Caption object. Optionally takes a block. If
14
- # an argument is provided it is treated as content.
15
- #
16
- def initialize(arg = nil, &block)
17
- @html_begin = '<caption'
18
- @html_body = ''
19
- @html_end = '</caption>'
20
- instance_eval(&block) if block_given?
21
- self.content = arg if arg
22
- end
23
-
24
- # Adds content to the Table::Caption object.
25
- #
26
- def content=(arg)
27
- @html_body = Table::Content.new(arg.to_s)
28
- end
29
-
30
- # Returns the number of spaces that tags for this class are indented.
31
- # For the Table::Caption class, the indention level defaults to 3.
32
- #
33
- def self.indent_level
34
- @indent_level
35
- end
36
-
37
- # Sets the number of spaces that tags for this class are indented.
38
- #
39
- def self.indent_level=(num)
40
- expect(num,Integer)
41
- raise ArgumentError, "indent level must be >= 0" if num < 0
42
- @indent_level = num
43
- end
44
-
45
- alias to_s html
46
- alias to_str html
47
- end
48
- end
1
+ module HTML
2
+
3
+ # This class represents an HTML Caption. Despite the name, it is not
4
+ # a subclass of Table. Note that end tags for this class are mandatory.
5
+ #
6
+ class Table::Caption
7
+ include AttributeHandler
8
+ include HtmlHandler
9
+
10
+ undef_method :configure
11
+ @indent_level = 3
12
+
13
+ # Returns a new Table::Caption object. Optionally takes a block. If
14
+ # an argument is provided it is treated as content.
15
+ #
16
+ def initialize(arg = nil, &block)
17
+ @html_begin = '<caption'
18
+ @html_body = ''
19
+ @html_end = '</caption>'
20
+ instance_eval(&block) if block_given?
21
+ self.content = arg if arg
22
+ end
23
+
24
+ # Adds content to the Table::Caption object.
25
+ #
26
+ def content=(arg)
27
+ @html_body = Table::Content.new(arg.to_s)
28
+ end
29
+
30
+ # Returns the number of spaces that tags for this class are indented.
31
+ # For the Table::Caption class, the indention level defaults to 3.
32
+ #
33
+ def self.indent_level
34
+ @indent_level
35
+ end
36
+
37
+ # Sets the number of spaces that tags for this class are indented.
38
+ #
39
+ def self.indent_level=(num)
40
+ expect(num,Integer)
41
+ raise ArgumentError, "indent level must be >= 0" if num < 0
42
+ @indent_level = num
43
+ end
44
+
45
+ alias to_s html
46
+ alias to_str html
47
+ end
48
+ end
data/lib/html/col.rb CHANGED
@@ -1,41 +1,41 @@
1
- module HTML
2
- # This class represents an HTML ColGroup column (<col>). Despite the
3
- # name, it is not a subclass of ColGroup or Table.
4
- #
5
- class Table::ColGroup::Col
6
- include AttributeHandler
7
- include HtmlHandler
8
-
9
- undef_method :configure, :content
10
- @indent_level = 6
11
-
12
- # Creates and returns a new ColGroup object. Optionally takes a block.
13
- # Note that it does not accept an argument - col tags do not have content.
14
- #
15
- def initialize(&block)
16
- @html_begin = '<col'
17
- @html_body = ''
18
- @html_end = ''
19
- instance_eval(&block) if block_given?
20
- end
21
-
22
- # Returns the indentation level for the tags of this class. The
23
- # default is 6.
24
- #
25
- def self.indent_level
26
- @indent_level
27
- end
28
-
29
- # Sets the indentation level for the tags of this class. The default
30
- # is 6.
31
- #
32
- def self.indent_level=(num)
33
- expect(num,Integer)
34
- raise ArgumentError, "num must be >= 0" if num < 0
35
- @indent_level = num
36
- end
37
-
38
- alias to_s html
39
- alias to_str html
40
- end
41
- end
1
+ module HTML
2
+ # This class represents an HTML ColGroup column (<col>). Despite the
3
+ # name, it is not a subclass of ColGroup or Table.
4
+ #
5
+ class Table::ColGroup::Col
6
+ include AttributeHandler
7
+ include HtmlHandler
8
+
9
+ undef_method :configure, :content
10
+ @indent_level = 6
11
+
12
+ # Creates and returns a new ColGroup object. Optionally takes a block.
13
+ # Note that it does not accept an argument - col tags do not have content.
14
+ #
15
+ def initialize(&block)
16
+ @html_begin = '<col'
17
+ @html_body = ''
18
+ @html_end = ''
19
+ instance_eval(&block) if block_given?
20
+ end
21
+
22
+ # Returns the indentation level for the tags of this class. The
23
+ # default is 6.
24
+ #
25
+ def self.indent_level
26
+ @indent_level
27
+ end
28
+
29
+ # Sets the indentation level for the tags of this class. The default
30
+ # is 6.
31
+ #
32
+ def self.indent_level=(num)
33
+ expect(num,Integer)
34
+ raise ArgumentError, "num must be >= 0" if num < 0
35
+ @indent_level = num
36
+ end
37
+
38
+ alias to_s html
39
+ alias to_str html
40
+ end
41
+ end
data/lib/html/colgroup.rb CHANGED
@@ -1,113 +1,113 @@
1
- module HTML
2
- # This class represents an HTML column group (<colgroup>). It is a
3
- # subclass of Array. The only elements it may contain are instances
4
- # of the ColGroup::Col class.
5
- #
6
- class Table::ColGroup < Array
7
- include AttributeHandler
8
- include HtmlHandler
9
-
10
- @indent_level = 3
11
- @end_tags = true
12
-
13
- undef_method :content
14
-
15
- # Returns a new ColGroup object. Optionally takes a block. If an
16
- # argument is provided, it is treated as content.
17
- #
18
- def initialize(arg = nil, &block)
19
- @html_begin = '<colgroup'
20
- @html_body = ''
21
- @html_end = '</colgroup>'
22
- instance_eval(&block) if block_given?
23
- self.push(arg) if arg
24
- end
25
-
26
- # Returns the indentation level for the tags of this class. The
27
- # default is 3.
28
- #
29
- def self.indent_level
30
- @indent_level
31
- end
32
-
33
- # Sets the indentation level for the tags of this class. The default
34
- # is 3.
35
- #
36
- def self.indent_level=(num)
37
- expect(num,Integer)
38
- raise ArgumentError,"indent_level must be >= 0" if num < 0
39
- @indent_level = num
40
- end
41
-
42
- # This method has been redefined to only allow ColGroup::Col objects
43
- # to be assigned.
44
- #
45
- def []=(index,obj)
46
- if obj.kind_of?(Array)
47
- expect(obj.first,Col) # In case of 0 length Array
48
- obj.each{ |o|
49
- expect(o,Col)
50
- }
51
- else
52
- expect(obj,Col)
53
- end
54
- super
55
- end
56
-
57
- # This method has been redefined to only allow ColGroup::Col objects
58
- # to be pushed onto a ColGroup instance.
59
- #
60
- def push(*args)
61
- args.each do |obj|
62
- unless obj.kind_of?(Table::ColGroup::Col)
63
- msg = "Can only assign Col objects to ColGroup class"
64
- msg += ": " + obj.class.to_s
65
- raise TypeError, msg
66
- end
67
- super(obj)
68
- end
69
- end
70
-
71
- # This method has been redefined to only allow ColGroup::Col objects
72
- # to be pushed onto a ColGroup instance.
73
- #
74
- def <<(obj)
75
- unless obj.kind_of?(Table::ColGroup::Col)
76
- msg = "Can only assign Col objects to ColGroup class"
77
- msg += ": " + obj.class.to_s
78
- raise TypeError, msg
79
- end
80
- super(obj)
81
- end
82
-
83
- # This method has been redefined to only allow ColGroup::Col objects
84
- # to be unshifted onto a ColGroup instance.
85
- #
86
- def unshift(obj)
87
- unless obj.kind_of?(Table::ColGroup::Col)
88
- msg = "Can only assign Data and Header objects to Row class"
89
- raise TypeError, msg
90
- end
91
- super
92
- end
93
-
94
- # Returns a boolean indicating whether or not end tags are included for
95
- # each ColGroup object in the final HTML output. The default is true.
96
- #
97
- def self.end_tags?
98
- @end_tags
99
- end
100
-
101
- # Sets whether or not end tags are included for each ColGroup object in
102
- # the final HTML output. The default is true. Only true or false are
103
- # valid arguments.
104
- #
105
- def self.end_tags=(bool)
106
- expect(bool,[TrueClass,FalseClass])
107
- @end_tags = bool
108
- end
109
-
110
- alias to_s html
111
- alias to_str html
112
- end
113
- end
1
+ module HTML
2
+ # This class represents an HTML column group (<colgroup>). It is a
3
+ # subclass of Array. The only elements it may contain are instances
4
+ # of the ColGroup::Col class.
5
+ #
6
+ class Table::ColGroup < Array
7
+ include AttributeHandler
8
+ include HtmlHandler
9
+
10
+ @indent_level = 3
11
+ @end_tags = true
12
+
13
+ undef_method :content
14
+
15
+ # Returns a new ColGroup object. Optionally takes a block. If an
16
+ # argument is provided, it is treated as content.
17
+ #
18
+ def initialize(arg = nil, &block)
19
+ @html_begin = '<colgroup'
20
+ @html_body = ''
21
+ @html_end = '</colgroup>'
22
+ instance_eval(&block) if block_given?
23
+ self.push(arg) if arg
24
+ end
25
+
26
+ # Returns the indentation level for the tags of this class. The
27
+ # default is 3.
28
+ #
29
+ def self.indent_level
30
+ @indent_level
31
+ end
32
+
33
+ # Sets the indentation level for the tags of this class. The default
34
+ # is 3.
35
+ #
36
+ def self.indent_level=(num)
37
+ expect(num,Integer)
38
+ raise ArgumentError,"indent_level must be >= 0" if num < 0
39
+ @indent_level = num
40
+ end
41
+
42
+ # This method has been redefined to only allow ColGroup::Col objects
43
+ # to be assigned.
44
+ #
45
+ def []=(index,obj)
46
+ if obj.kind_of?(Array)
47
+ expect(obj.first,Col) # In case of 0 length Array
48
+ obj.each{ |o|
49
+ expect(o,Col)
50
+ }
51
+ else
52
+ expect(obj,Col)
53
+ end
54
+ super
55
+ end
56
+
57
+ # This method has been redefined to only allow ColGroup::Col objects
58
+ # to be pushed onto a ColGroup instance.
59
+ #
60
+ def push(*args)
61
+ args.each do |obj|
62
+ unless obj.kind_of?(Table::ColGroup::Col)
63
+ msg = "Can only assign Col objects to ColGroup class"
64
+ msg += ": " + obj.class.to_s
65
+ raise TypeError, msg
66
+ end
67
+ super(obj)
68
+ end
69
+ end
70
+
71
+ # This method has been redefined to only allow ColGroup::Col objects
72
+ # to be pushed onto a ColGroup instance.
73
+ #
74
+ def <<(obj)
75
+ unless obj.kind_of?(Table::ColGroup::Col)
76
+ msg = "Can only assign Col objects to ColGroup class"
77
+ msg += ": " + obj.class.to_s
78
+ raise TypeError, msg
79
+ end
80
+ super(obj)
81
+ end
82
+
83
+ # This method has been redefined to only allow ColGroup::Col objects
84
+ # to be unshifted onto a ColGroup instance.
85
+ #
86
+ def unshift(obj)
87
+ unless obj.kind_of?(Table::ColGroup::Col)
88
+ msg = "Can only assign Data and Header objects to Row class"
89
+ raise TypeError, msg
90
+ end
91
+ super
92
+ end
93
+
94
+ # Returns a boolean indicating whether or not end tags are included for
95
+ # each ColGroup object in the final HTML output. The default is true.
96
+ #
97
+ def self.end_tags?
98
+ @end_tags
99
+ end
100
+
101
+ # Sets whether or not end tags are included for each ColGroup object in
102
+ # the final HTML output. The default is true. Only true or false are
103
+ # valid arguments.
104
+ #
105
+ def self.end_tags=(bool)
106
+ expect(bool,[TrueClass,FalseClass])
107
+ @end_tags = bool
108
+ end
109
+
110
+ alias to_s html
111
+ alias to_str html
112
+ end
113
+ end