-
Notifications
You must be signed in to change notification settings - Fork 1
/
demo.rb
186 lines (172 loc) · 4.38 KB
/
demo.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
# frozen_string_literal: true
require_relative 'lib/tabled'
STAR_WARS_CHARACTERS = [
{
name: 'Luke Skywalker',
height: '172',
mass: '77',
hair_color: 'blond',
skin_color: 'fair',
eye_color: 'blue',
birth_year: '19BBY',
gender: 'male'
},
{
name: 'C-3PO',
height: '167',
mass: '75',
hair_color: 'n/a',
skin_color: 'gold',
eye_color: 'yellow',
birth_year: '112BBY',
gender: 'n/a'
},
{
name: 'R2-D2',
height: '96',
mass: '32',
hair_color: 'n/a',
skin_color: 'white, blue',
eye_color: 'red',
birth_year: '33BBY',
gender: 'n/a'
},
{
name: 'Darth Vader',
height: '202',
mass: '136',
hair_color: 'none',
skin_color: 'white',
eye_color: 'yellow',
birth_year: '41.9BBY',
gender: 'male'
},
{
name: 'Leia Organa',
height: '150',
mass: '49',
hair_color: 'brown',
skin_color: 'light',
eye_color: 'brown',
birth_year: '19BBY',
gender: 'female'
},
{
name: 'Owen Lars',
height: '178',
mass: '120',
hair_color: 'brown, grey',
skin_color: 'light',
eye_color: 'blue',
birth_year: '52BBY',
gender: 'male'
},
{
name: 'Beru Whitesun lars',
height: '165',
mass: '75',
hair_color: 'brown',
skin_color: 'light',
eye_color: 'blue',
birth_year: '47BBY',
gender: 'female'
},
{
name: 'R5-D4',
height: '97',
mass: '32',
hair_color: 'n/a',
skin_color: 'white, red',
eye_color: 'red',
birth_year: 'unknown',
gender: 'n/a'
},
{
name: 'Biggs Darklighter',
height: '183',
mass: '84',
hair_color: 'black',
skin_color: 'light',
eye_color: 'brown',
birth_year: '24BBY',
gender: 'male'
},
{
name: 'Obi-Wan Kenobi',
height: '182',
mass: '77',
hair_color: 'auburn, white',
skin_color: 'fair',
eye_color: 'blue-gray',
birth_year: '57BBY',
gender: 'male'
}
].freeze
print "Printing without any params: \n"
data = STAR_WARS_CHARACTERS.map do |character|
[character[:name], character[:height], character[:gender]]
end
Tabled.new(data).print_to_console
# ---------------------------------
# | Luke Skywalker 172 male |
# ---------------------------------
# | C-3PO 167 n/a |
# ---------------------------------
# | R2-D2 96 n/a |
# ---------------------------------
# | Darth Vader 202 male |
# ---------------------------------
# | Leia Organa 150 female |
# ---------------------------------
# | Owen Lars 178 male |
# ---------------------------------
# | Beru Whitesun lars 165 female |
# ---------------------------------
# | R5-D4 97 n/a |
# ---------------------------------
# | Biggs Darklighter 183 male |
# ---------------------------------
# | Obi-Wan Kenobi 182 male |
# ---------------------------------
print "\n\n############################\n\n"
print "Printing without frame: \n"
data = STAR_WARS_CHARACTERS.map do |character|
[character[:name], character[:height], character[:gender]]
end
Tabled.new(data, framed: false).print_to_console
# Luke Skywalker 172 male
# ---------------------------------
# C-3PO 167 n/a
# ---------------------------------
# R2-D2 96 n/a
# ---------------------------------
# Darth Vader 202 male
# ---------------------------------
# Leia Organa 150 female
# ---------------------------------
# Owen Lars 178 male
# ---------------------------------
# Beru Whitesun lars 165 female
# ---------------------------------
# R5-D4 97 n/a
# ---------------------------------
# Biggs Darklighter 183 male
# ---------------------------------
# Obi-Wan Kenobi 182 male
# ---------------------------------
print "\n\n############################\n\n"
print "Printing without frame: and row separator\n"
data = STAR_WARS_CHARACTERS.map do |character|
[character[:name], character[:height], character[:gender], { footer: 'One very long footer! Be carefull' }]
end
Tabled.new(data, titles: %w[Name Height Gender]).print_to_console
# Luke Skywalker 172 male
# C-3PO 167 n/a
# R2-D2 96 n/a
# Darth Vader 202 male
# Leia Organa 150 female
# Owen Lars 178 male
# Beru Whitesun lars 165 female
# R5-D4 97 n/a
# Biggs Darklighter 183 male
# Obi-Wan Kenobi 182 male