Class: PackageProtections::Private::ColorizedString

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/package_protections/private/colorized_string.rb

Defined Under Namespace

Classes: Color

Instance Method Summary collapse

Constructor Details

#initialize(original_string, color = Color::White) ⇒ ColorizedString

Returns a new instance of ColorizedString.



23
24
25
26
# File 'lib/package_protections/private/colorized_string.rb', line 23

def initialize(original_string, color = Color::White)
  @original_string = original_string
  @color = color
end

Instance Method Details

#blueObject



54
55
56
# File 'lib/package_protections/private/colorized_string.rb', line 54

def blue
  colorize(Color::Blue)
end

#colorized_to_sObject



29
30
31
# File 'lib/package_protections/private/colorized_string.rb', line 29

def colorized_to_s
  "\e[#{color_code}m#{@original_string}\e[0m"
end

#greenObject



44
45
46
# File 'lib/package_protections/private/colorized_string.rb', line 44

def green
  colorize(Color::Green)
end

#light_blueObject



64
65
66
# File 'lib/package_protections/private/colorized_string.rb', line 64

def light_blue
  colorize(Color::LightBlue)
end

#pinkObject



59
60
61
# File 'lib/package_protections/private/colorized_string.rb', line 59

def pink
  colorize(Color::Pink)
end

#redObject



39
40
41
# File 'lib/package_protections/private/colorized_string.rb', line 39

def red
  colorize(Color::Red)
end

#to_sObject



34
35
36
# File 'lib/package_protections/private/colorized_string.rb', line 34

def to_s
  @original_string
end

#whiteObject



69
70
71
# File 'lib/package_protections/private/colorized_string.rb', line 69

def white
  colorize(Color::White)
end

#yellowObject



49
50
51
# File 'lib/package_protections/private/colorized_string.rb', line 49

def yellow
  colorize(Color::Yellow)
end