Class: Skywatch::Script

Inherits:
Object
  • Object
show all
Defined in:
lib/skywatch/tool.rb

Direct Known Subclasses

Alert, Check

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Script

Returns a new instance of Script.



173
174
175
176
# File 'lib/skywatch/tool.rb', line 173

def initialize(path)
  @path = path
  @name = File.basename(path)
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



167
168
169
# File 'lib/skywatch/tool.rb', line 167

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



166
167
168
# File 'lib/skywatch/tool.rb', line 166

def path
  @path
end

Class Method Details

.[](path) ⇒ Object



169
170
171
# File 'lib/skywatch/tool.rb', line 169

def self.[](path)
  self.new(path)
end

Instance Method Details

#destroyObject



191
192
193
# File 'lib/skywatch/tool.rb', line 191

def destroy
  rm @path
end

#disableObject



186
187
188
189
# File 'lib/skywatch/tool.rb', line 186

def disable
  enable # since this is relative, force 0700
  chmod File.stat(@path).mode & ~0100, @path
end

#enableObject



182
183
184
# File 'lib/skywatch/tool.rb', line 182

def enable
  chmod File.stat(@path).mode | 0700, @path
end

#enabled?Boolean

Returns:

  • (Boolean)


178
179
180
# File 'lib/skywatch/tool.rb', line 178

def enabled?
  File.executable? @path
end