Class: SysCmd::Shell
- Inherits:
-
Object
- Object
- SysCmd::Shell
- Defined in:
- lib/sys_cmd.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #applicable?(options = {}) ⇒ Boolean
- #escape(text) ⇒ Object
- #escape_filename(name) ⇒ Object
- #escape_value(value) ⇒ Object
-
#initialize(options = {}) ⇒ Shell
constructor
A new instance of Shell.
- #line_separator ⇒ Object
- #option_switch ⇒ Object
- #split(text) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Shell
Returns a new instance of Shell.
411 412 413 |
# File 'lib/sys_cmd.rb', line 411 def initialize( = {}) @type = SysCmd.os_type() end |
Instance Attribute Details
#type ⇒ Object (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
444 445 446 447 448 449 450 451 452 453 454 455 |
# File 'lib/sys_cmd.rb', line 444 def applicable?( = {}) applicable = true only_on = Array([:only_on]) unless only_on.empty? applicable = false unless only_on.include?(@type) end except_on = Array([: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_separator ⇒ Object
436 437 438 |
# File 'lib/sys_cmd.rb', line 436 def line_separator SysCmd.line_separator(os: @type) end |
#option_switch ⇒ Object
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 |