Module: Wat

Defined in:
lib/wat-shell.rb

Constant Summary collapse

VERSION =
'0.0.1'

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/wat-shell.rb', line 4

def self.included(base)
  base.instance_eval do
    def respond_to_missing?(method, *args)
      `which #{method}` != ""
    end

    def method_missing(method, *args)
      if respond_to_missing?(method, *args)
        `#{method} #{args.join(' ')}`.split("\n")
      else
        [method, *args].join(' ')
      end
    end

    def Object.const_missing(const)
      const.to_s
    end
  end
end