Class: SysCmd::Shell

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Shell

Returns a new instance of Shell.



328
329
330
# File 'lib/sys_cmd.rb', line 328

def initialize(options = {})
  @type = SysCmd.os_type(options)
end

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



332
333
334
# File 'lib/sys_cmd.rb', line 332

def type
  @type
end

Instance Method Details

#applicable?(options = {}) ⇒ Boolean

Returns:

  • (Boolean)


354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/sys_cmd.rb', line 354

def applicable?(options = {})
  applicable = true
  only_on = Array(options[:only_on])
  unless only_on.empty?
    applicable = false unless only_on.include?(@type)
  end
  except_on = Array(options[:except_on])
  unless except_on.empty?
    applicable = false if except_on.include?(@type)
  end
  applicable
end

#escape(text) ⇒ Object



334
335
336
# File 'lib/sys_cmd.rb', line 334

def escape(text)
  SysCmd.escape(text, os: @type)
end

#escape_filename(name) ⇒ Object



338
339
340
# File 'lib/sys_cmd.rb', line 338

def escape_filename(name)
  escape name
end

#escape_value(value) ⇒ Object



342
343
344
# File 'lib/sys_cmd.rb', line 342

def escape_value(value)
  escape value.to_s
end

#line_separatorObject



346
347
348
# File 'lib/sys_cmd.rb', line 346

def line_separator
  SysCmd.line_separator(os: @type)
end

#option_switchObject



350
351
352
# File 'lib/sys_cmd.rb', line 350

def option_switch
  SysCmd.option_switch(os: @type)
end