File: polychrome.rb

package info (click to toggle)
ruby-memory-profiler 1.1.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 284 kB
  • sloc: ruby: 1,128; makefile: 4
file content (95 lines) | stat: -rw-r--r-- 1,305 bytes parent folder | download
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
# frozen_string_literal: true

module MemoryProfiler

  class Polychrome

    def path(text)
      blue(text)
    end

    def string(text)
      green(text)
    end

    def line(text)
      cyan(text)
    end

    private

    def black(str)
      "\033[30m#{str}\033[0m"
    end

    def red(str)
      "\033[31m#{str}\033[0m"
    end

    def green(str)
      "\033[32m#{str}\033[0m"
    end

    def brown(str)
      "\033[33m#{str}\033[0m"
    end

    def blue(str)
      "\033[34m#{str}\033[0m"
    end

    def magenta(str)
      "\033[35m#{str}\033[0m"
    end

    def cyan(str)
      "\033[36m#{str}\033[0m"
    end

    def gray(str)
      "\033[37m#{str}\033[0m"
    end

    def bg_black(str)
      "\033[40m#{str}\033[0m"
    end

    def bg_red(str)
      "\033[41m#{str}\033[0m"
    end

    def bg_green(str)
      "\033[42m#{str}\033[0m"
    end

    def bg_brown(str)
      "\033[43m#{str}\033[0m"
    end

    def bg_blue(str)
      "\033[44m#{str}\033[0m"
    end

    def bg_magenta(str)
      "\033[45m#{str}\033[0m"
    end

    def bg_cyan(str)
      "\033[46m#{str}\033[0m"
    end

    def bg_gray(str)
      "\033[47m#{str}\033[0m"
    end

    def bold(str)
      "\033[1m#{str}\033[22m"
    end

    def reverse_color(str)
      "\033[7m#{str}\033[27m"
    end

  end

end