summaryrefslogtreecommitdiffhomepage
path: root/mrbgems/mruby-io/mrblib/kernel.rb
blob: 42d5bb1d163d6701ed91c9390d044736150d55fd (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
32
33
34
35
module Kernel
  def `(cmd)
    IO.popen(cmd) { |io| io.read }
  end

  def open(file, *rest, &block)
    raise ArgumentError unless file.is_a?(String)

    if file[0] == "|"
      IO.popen(file[1..-1], *rest, &block)
    else
      File.open(file, *rest, &block)
    end
  end

  def print(*args)
    $stdout.print(*args)
  end

  def puts(*args)
    $stdout.puts(*args)
  end

  def printf(*args)
    $stdout.printf(*args)
  end

  def gets(*args)
    $stdin.gets(*args)
  end

  def getc(*args)
    $stdin.getc(*args)
  end
end