Class: Formatador

Inherits:
Object
  • Object
show all
Defined in:
lib/dgit/log.rb

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.levelObject

Returns the value of attribute level.



24
25
26
# File 'lib/dgit/log.rb', line 24

def level
  @level
end

Class Method Details

.debug(str) ⇒ Object



31
32
33
# File 'lib/dgit/log.rb', line 31

def self.debug(str)
	Formatador.display_line(str) if visible(__method__)
end

.error(str) ⇒ Object



43
44
45
# File 'lib/dgit/log.rb', line 43

def self.error(str)
	Formatador.display_line("[red]#{str}[/]") if visible(__method__)
end

.info(str) ⇒ Object



27
28
29
# File 'lib/dgit/log.rb', line 27

def self.info(str)
	Formatador.display_line(str) if visible(__method__)
end

.ok(str) ⇒ Object



35
36
37
# File 'lib/dgit/log.rb', line 35

def self.ok(str)
	Formatador.display_line("[green]#{str}[/]") if visible(__method__)
end

.visible(method) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/dgit/log.rb', line 47

def self.visible(method)
	target = method.to_sym
	if %i[ok error info].include?(target)
		true
	elsif (target == :warn || target == :debug) && level == :fine
		true
	else
		false
	end
end

.warn(str) ⇒ Object



39
40
41
# File 'lib/dgit/log.rb', line 39

def self.warn(str)
	Formatador.display_line("[yellow]#{str}[/]") if visible(__method__)
end