summaryrefslogtreecommitdiff
path: root/golf_prelude.rb
blob: 03c0c6cceb41bd1f6b4de4ab31ba668bb2dd99f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
SCRIPT_LINES__={}

class Object
  def method_missing m, *a, &b
    r = /^#{m}/
    t = (methods + private_methods).sort.find{|e|r=~e}
    t ? __send__(t, *a, &b) : super
  end

  def self.const_missing c
    r = /^#{c}/
    t = constants.sort.find{|e|r=~e}
    t ? const_get(t) : superclass.const_get(c)
  end

  def h(a='H', b='w', c='!')
    puts "#{a}ello, #{b}orld#{c}"
  end

  def quine(src = $0)
    SCRIPT_LINES__[src].join
  end
end

class Integer
  def each(&b)
    times &b
  end

  include Enumerable
end