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.



411
412
413
# File 'lib/sys_cmd.rb', line 411

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

Instance Attribute Details

#typeObject (readonly)

Returns the value of attribute type.



415
416
417
# File 'lib/sys_cmd.rb', line 415

def type
  @type
end

Instance Method Details

#applicable?(options = {}) ⇒ Boolean

Returns:



444
445
446
447
448
449
450
451
452
453
454
455
# File 'lib/sys_cmd.rb', line 444

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



417
418
419
# File 'lib/sys_cmd.rb', line 417

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

#escape_filename(name) ⇒ Object



425
426
427
428
429
430
# File 'lib/sys_cmd.rb', line 425

def escape_filename(name)
  if @type == :windows
    name = name.gsub('/', '\\')
  end
  escape name
end

#escape_value(value) ⇒ Object



432
433
434
# File 'lib/sys_cmd.rb', line 432

def escape_value(value)
  escape value.to_s
end

#line_separatorObject



436
437
438
# File 'lib/sys_cmd.rb', line 436

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

#option_switchObject



440
441
442
# File 'lib/sys_cmd.rb', line 440

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

#split(text) ⇒ Object



421
422
423
# File 'lib/sys_cmd.rb', line 421

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