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.



377
378
379
# File 'lib/sys_cmd.rb', line 377

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

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



381
382
383
# File 'lib/sys_cmd.rb', line 381

def type
  @type
end

Instance Method Details

#applicable?(options = {}) ⇒ Boolean

Returns:



407
408
409
410
411
412
413
414
415
416
417
418
# File 'lib/sys_cmd.rb', line 407

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



383
384
385
# File 'lib/sys_cmd.rb', line 383

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

#escape_filename(name) ⇒ Object



391
392
393
# File 'lib/sys_cmd.rb', line 391

def escape_filename(name)
  escape name
end

#escape_value(value) ⇒ Object



395
396
397
# File 'lib/sys_cmd.rb', line 395

def escape_value(value)
  escape value.to_s
end

#line_separatorObject



399
400
401
# File 'lib/sys_cmd.rb', line 399

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

#option_switchObject



403
404
405
# File 'lib/sys_cmd.rb', line 403

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

#split(text) ⇒ Object



387
388
389
# File 'lib/sys_cmd.rb', line 387

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