tidy_table 0.0.2 → 0.0.3

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.
Files changed (3) hide show
  1. data/History.txt +4 -0
  2. data/lib/tidy_table.rb +15 -3
  3. metadata +1 -1
@@ -1,3 +1,7 @@
1
+ == 0.0.3 / 2007-06-24
2
+
3
+ * Added automatic last_column_class to header row also
4
+
1
5
  == 0.0.2 / 2007-06-24
2
6
 
3
7
  * Added automatic last_column_class and related options
@@ -15,8 +15,18 @@
15
15
 
16
16
  class TidyTable
17
17
 
18
- VERSION = '0.0.2'
18
+ VERSION = '0.0.3'
19
19
 
20
+ ##
21
+ # Make a new TidyTable with a data array and CSS options.
22
+ #
23
+ # * :table_class -- Defaults to 'tidytable'
24
+ # * :first_row_class -- Defaults to 'first_row'
25
+ # * :first_column_class -- Defaults to 'first_column'
26
+ # * :last_column_class -- Defaults to 'last_column'
27
+ #
28
+ # You also get 'even' and 'odd' for free (rows only).
29
+
20
30
  def initialize(array, options={})
21
31
  @rows = array
22
32
  @options = {
@@ -41,7 +51,7 @@ class TidyTable
41
51
  # First row
42
52
  output << %(<tr class="#{@options[:first_row_class]}">)
43
53
  fields.each_with_index do |field, index|
44
- output << %(<th class="#{@options[:first_row_class]} #{ index == 0 ? @options[:first_column_class] : ''}">#{field}</th>)
54
+ output << %(<th class="#{@options[:first_row_class]} #{column_classes(fields, index)}">#{field}</th>)
45
55
  end
46
56
  output << "</tr>"
47
57
 
@@ -50,7 +60,7 @@ class TidyTable
50
60
  if block_given?
51
61
  formatted_data = yield(row)
52
62
  formatted_data.each_with_index do |data, index|
53
- output << %(<td class="#{column_classes(fields, index)}">#{data}</td>)
63
+ output << %(<td class="#{column_classes(formatted_data, index)}">#{data}</td>)
54
64
  end
55
65
  else
56
66
  fields.each_with_index do |field, index|
@@ -62,6 +72,8 @@ class TidyTable
62
72
  output << "</table>"
63
73
  output.join
64
74
  end
75
+
76
+ private
65
77
 
66
78
  ##
67
79
  # Returns "first_column", "last_column", or both.
metadata CHANGED
@@ -3,7 +3,7 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: tidy_table
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.0.2
6
+ version: 0.0.3
7
7
  date: 2007-06-24 00:00:00 -07:00
8
8
  summary: Yet another library for converting a struct into an HTML table.
9
9
  require_paths: