-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils.rb
41 lines (34 loc) · 920 Bytes
/
utils.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
module Stepper
require 'text-table'
class Utils
def self.get_class_by_name(module_name, class_name)
Object.const_get(module_name).const_get(class_name)
end
def self.get_abs_path_from_file(file, relative_path)
filedir = Pathname(file).parent
File.join(File.expand_path(filedir), relative_path)
end
def self.write_h1(text)
self.write_header('=', text)
end
def self.write_h2(text)
self.write_header('*', text)
end
def self.write_h3(text)
self.write_header('-', text)
end
def self.write_header(character, text)
len = text.size + 4*2
puts character * len
puts character * 3 + " #{text} " + character * 3
puts character * len
end
def self.print_hash_as_text_table(hash)
table = Text::Table.new(
:head => hash.keys,
:rows => [hash.values]
)
puts table
end
end
end