Class: Kanrisuru::Util::Signal

Inherits:
Object
  • Object
show all
Defined in:
lib/kanrisuru/util/signal.rb

Class Method Summary collapse

Class Method Details

.[](signal) ⇒ Object



136
137
138
139
140
141
142
143
144
# File 'lib/kanrisuru/util/signal.rb', line 136

def self.[](signal)
  return unless valid?(signal)

  if signal.instance_of?(Integer)
    @linux_inverted[signal]
  else
    @linux[translate(signal)]
  end
end

.translate(signal) ⇒ Object



156
157
158
# File 'lib/kanrisuru/util/signal.rb', line 156

def self.translate(signal)
  signal.gsub('SIG', '')
end

.valid?(signal) ⇒ Boolean

Returns:

  • (Boolean)


146
147
148
149
150
151
152
153
154
# File 'lib/kanrisuru/util/signal.rb', line 146

def self.valid?(signal)
  if signal.instance_of?(Integer)
    @linux_inverted.key?(signal)
  elsif signal.instance_of?(String)
    @linux.key?(translate(signal))
  else
    raise ArgumentError, 'Invalid data type'
  end
end