Class: Yap::Shell::FileSystemCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/yap/shell/commands.rb

Instance Attribute Summary

Attributes inherited from Command

#args, #heredoc, #line, #str, #world

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

#initialize

Constructor Details

This class inherits a constructor from Yap::Shell::Command

Class Method Details

.===(other) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
# File 'lib/yap/shell/commands.rb', line 95

def self.===(other)
  command = other.split(/\s+/).detect{ |f| !f.include?("=") }

  # Check to see if the user gave us a valid path to execute
  return true if File.executable?(command)

  # See if the command exists anywhere on the path
  world.env["PATH"].split(":").detect do |path|
    File.executable?(File.join(path, command))
  end
end

.worldObject



91
92
93
# File 'lib/yap/shell/commands.rb', line 91

def self.world
  ::Yap::World.instance
end

Instance Method Details

#to_executable_strObject



117
118
119
120
121
122
# File 'lib/yap/shell/commands.rb', line 117

def to_executable_str
  [
    str,
    args.join(' ')
  ].join(' ')
end

#to_sObject Also known as: to_str, inspect



111
112
113
# File 'lib/yap/shell/commands.rb', line 111

def to_s
  "#{self.class.name}(#{to_executable_str.inspect})"
end

#typeObject



107
108
109
# File 'lib/yap/shell/commands.rb', line 107

def type
  :FileSystemCommand
end