Module: Libconsole::Linux::Raw

Included in:
Raw, MyClass
Defined in:
lib/libconsole/linux/raw.rb

Instance Method Summary collapse

Instance Method Details

#alert(*argv) ⇒ Object



58
59
60
# File 'lib/libconsole/linux/raw.rb', line 58

def alert(*argv)
  pre_puts argv, "aler"
end

#assert(assertion = false, *args) ⇒ Object



70
71
72
# File 'lib/libconsole/linux/raw.rb', line 70

def assert(assertion = false, *args)
  pre_puts args, "asse" unless assertion
end

#clearObject



74
75
76
# File 'lib/libconsole/linux/raw.rb', line 74

def clear
  !Gem.win_platform? ? (system "clear") : (system "cls")
end

#count(*argv) ⇒ Object



78
79
80
81
82
83
# File 'lib/libconsole/linux/raw.rb', line 78

def count(*argv)
  label = argv.empty? ? "default" : argv.shift
  @count_state[label.to_sym] = 0 unless @count_state[label.to_sym]
  @count_state[label.to_sym] += 1
  pre_puts [label, @count_state[label.to_sym], argv], "coun"
end

#count_reset(*argv) ⇒ Object



85
86
87
88
89
90
91
92
93
# File 'lib/libconsole/linux/raw.rb', line 85

def count_reset(*argv)
  label = argv.empty? ? "default" : argv.shift
  unless @count_state[label.to_sym]
    pre_puts "Count for '#{label}' does not exist", "warn"
    return
  end
  @count_state[label.to_sym] = 0
  pre_puts [label, @count_state[label.to_sym], argv], "coun"
end

#crit(*argv) ⇒ Object



54
55
56
# File 'lib/libconsole/linux/raw.rb', line 54

def crit(*argv)
  pre_puts argv, "crit"
end

#debug(*argv) ⇒ Object



66
67
68
# File 'lib/libconsole/linux/raw.rb', line 66

def debug(*argv)
  pre_puts argv, "debu" if @debug
end

#defaultObject



6
7
8
9
10
# File 'lib/libconsole/linux/raw.rb', line 6

def default
  @debug = false
  @count_state = {}
  @time_start_state = {}
end

#emerg(*argv) ⇒ Object



62
63
64
# File 'lib/libconsole/linux/raw.rb', line 62

def emerg(*argv)
  pre_puts argv, "emer"
end

#err(*argv) ⇒ Object



50
51
52
# File 'lib/libconsole/linux/raw.rb', line 50

def err(*argv)
  pre_puts argv, "erro"
end

#info(*argv) ⇒ Object

dmesg -h

Supported log levels (priorities):

 emerg - system is unusable
 alert - action must be taken immediately
  crit - critical conditions
   err - error conditions
  warn - warning conditions
notice - normal but significant condition
  info - informational
 debug - debug-level messages


38
39
40
# File 'lib/libconsole/linux/raw.rb', line 38

def info(*argv)
  pre_puts argv, "info"
end

#notice(*argv) ⇒ Object



42
43
44
# File 'lib/libconsole/linux/raw.rb', line 42

def notice(*argv)
  pre_puts argv, "noti"
end

#time(*argv) ⇒ Object



95
96
97
98
99
100
101
102
103
# File 'lib/libconsole/linux/raw.rb', line 95

def time(*argv)
  label = argv.empty? ? "default" : argv.shift
  if @time_start_state[label.to_sym]
    pre_puts "Timer '#{label}' already exists", "warn"
  else
    @time_start_state[label.to_sym] = Time.now
    pre_puts [label, argv], 0.0
  end
end

#time_end(*argv) ⇒ Object



105
106
107
108
109
110
111
112
113
114
115
# File 'lib/libconsole/linux/raw.rb', line 105

def time_end(*argv)
  label = argv.empty? ? "default" : argv.shift
  unless @time_start_state[label.to_sym]
    pre_puts "Timer '#{label}' does not exist", "warn"
    return
  end
  now = Time.now
  range = now - @time_start_state[label.to_sym]
  pre_puts [label, "timer ended", argv], range.to_f
  @time_start_state[label.to_sym] = nil
end

#time_log(*argv) ⇒ Object



117
118
119
120
121
122
123
124
125
126
# File 'lib/libconsole/linux/raw.rb', line 117

def time_log(*argv)
  label = argv.empty? ? "default" : argv.shift
  unless @time_start_state[label.to_sym]
    pre_puts "Timer '#{label}' does not exist", "warn"
    return
  end
  now = Time.now
  range = now - @time_start_state[label.to_sym]
  pre_puts [label, argv], range.to_f
end

#warn(*argv) ⇒ Object



46
47
48
# File 'lib/libconsole/linux/raw.rb', line 46

def warn(*argv)
  pre_puts argv, "warn"
end