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



83
84
85
86
87
88
89
90
91
92
93
# File 'lib/yap/shell/commands.rb', line 83

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



79
80
81
# File 'lib/yap/shell/commands.rb', line 79

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

Instance Method Details

#to_executable_strObject



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

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

#to_sObject Also known as: to_str, inspect



99
100
101
# File 'lib/yap/shell/commands.rb', line 99

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

#typeObject



95
96
97
# File 'lib/yap/shell/commands.rb', line 95

def type
  :FileSystemCommand
end