-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample
More file actions
executable file
·49 lines (39 loc) · 1.15 KB
/
example
File metadata and controls
executable file
·49 lines (39 loc) · 1.15 KB
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
#!/usr/bin/env ruby
# -*- ruby -*-
require 'lib/easytable'
include EasyTable
def main(argv)
# === Simple example ===
puts '=== Simple ==='
t = Table.from_array [[1,2,3],
[4,5,6],
[7,8,9]]
puts t or puts
# === Example with header ===
puts '=== Header ==='
t = Table.from_array([[ 'Name', 'Age', 'Favorite Donut'],
[ 'Joe', 19, 'Glazed'],
['Suzy Q', 45, 'Strawberry-filled'],
[ 'Bob', 25, 'I hate donuts']])
t.space = ' | '
t.underline_header = true
puts t or puts
# Allow for easier access to cell values
t.col_mnemonics = [:name,:age,:donut]
t.row_mnemonics = [:head,:joe,:suzy_q,:bob]
puts t or puts
# Updating values
t[2][1].value = 125234
t[:joe][:donut].value = 'Chocolate'
t.joe.age.value = 123
puts t or puts
# Formatting the output
t.head.color = Color::RED
t.joe.background = Color::BLUE
t.bob.donut.bold = true
t.bob.donut.underline = true
t.bob.donut.color = Color::YELLOW
t.bob.donut.background = Color::GREEN
puts t or puts
end
main ARGV