-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathtable.rb
60 lines (51 loc) · 999 Bytes
/
table.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
module Rgviz
class Table
attr_accessor :cols
attr_accessor :rows
def initialize
@cols = []
@rows = []
end
def to_csv
CsvRenderer.render self
end
def to_html
HtmlRenderer.render self
end
end
class Column
attr_accessor :id
attr_accessor :label
attr_accessor :type
attr_accessor :pattern
attr_accessor :role
attr_accessor :p
def initialize(attributes = {})
attributes.each do |key, value|
self.send "#{key}=", value
end
end
end
class Row
attr_accessor :c
def initialize(attributes = {})
if attributes.empty?
@c = []
else
attributes.each do |key, value|
self.send "#{key}=", value
end
end
end
end
class Cell
attr_accessor :v
attr_accessor :f
attr_accessor :p
def initialize(attributes = {})
attributes.each do |key, value|
self.send "#{key}=", value
end
end
end
end