Module: RBText::Formatting

Defined in:
lib/rbtext/formatting.rb

Class Method Summary collapse

Class Method Details

.blinking(mode: :str) ⇒ Object



39
40
41
42
43
# File 'lib/rbtext/formatting.rb', line 39

def self.blinking(mode: :str)
  r="\033[5m"
  return r if mode == :str
  print r if mode == :set
end

.bold(mode: :str) ⇒ Object



15
16
17
18
19
# File 'lib/rbtext/formatting.rb', line 15

def self.bold(mode: :str)
  r="\033[1m"
  return r if mode == :str
  print r if mode == :set
end

.faint(mode: :str) ⇒ Object



21
22
23
24
25
# File 'lib/rbtext/formatting.rb', line 21

def self.faint(mode: :str)
  r="\033[2m"
  return r if mode == :str
  print r if mode == :set
end

.italic(mode: :str) ⇒ Object



27
28
29
30
31
# File 'lib/rbtext/formatting.rb', line 27

def self.italic(mode: :str)
  r="\033[3m"
  return r if mode == :str
  print r if mode == :set
end

.reset(f_opt = nil, mode: :str) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/rbtext/formatting.rb', line 3

def self.reset(f_opt = nil, mode: :str)
  if f_opt
    r="\033[#{
      f_opt =~ /^\033\[(1|2)m$/ ? "\033[22m" : "\033[2#{f_opt.gsub(/[^0-9]/, "")}m"
    }"
  else
    r="\033[0m"
  end
  return r if mode == :str
  print r if mode == :set
end

.strikethrough(mode: :str) ⇒ Object



45
46
47
48
49
# File 'lib/rbtext/formatting.rb', line 45

def self.strikethrough(mode: :str)
  r="\033[9m"
  return r if mode == :str
  print r if mode == :set
end

.underline(mode: :str) ⇒ Object



33
34
35
36
37
# File 'lib/rbtext/formatting.rb', line 33

def self.underline(mode: :str)
  r="\033[4m"
  return r if mode == :str
  print r if mode == :set
end