Class: HxSys

Inherits:
Object
  • Object
show all
Defined in:
lib/lib/hx_sys.rb

Class Method Summary collapse

Class Method Details

.argsObject



6
7
8
# File 'lib/lib/hx_sys.rb', line 6

def HxSys.args 
  ARGV
end

.command(cmd, args = nil) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/lib/hx_sys.rb', line 39

def HxSys.command(cmd,args = nil)
  if args != nil 
    cmd = HxSys.escape_argument(cmd)
    begin
      _g = 0
      while(_g < args.length) 
        a = args[_g]
        _g+=1
        cmd += " " + _hx_str(HxSys.escape_argument(a))
      end
    end
  end
  result = nil
  if system(cmd) 
    result = 0
  else 
    result = 1
  end
  result
end

.escape_argument(arg) ⇒ Object

protected - in ruby this doesn’t play well with static/inline methods



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/lib/hx_sys.rb', line 16

def HxSys.escape_argument(arg)
  ok = true
  begin
    _g1 = 0
    _g = arg.length
    while(_g1 < _g) 
      i = _g1
      _g1+=1
      _g2 = (arg[i].ord rescue nil)
      case(_g2)
      when 32,34
        ok = false
      when 0,13,10
        arg = arg[0,i]
      end if _g2 != nil
    end
  end
  return arg if ok
  "\"" + _hx_str(arg.split("\"").join("\\\"")) + "\""
end

.exit(code) ⇒ Object



60
61
62
# File 'lib/lib/hx_sys.rb', line 60

def HxSys.exit(code)
  Kernel.exit(code)
end

.get_env(s) ⇒ Object



10
11
12
# File 'lib/lib/hx_sys.rb', line 10

def HxSys.get_env(s)
  getenv(s)
end

.stderrObject



68
69
70
# File 'lib/lib/hx_sys.rb', line 68

def HxSys.stderr 
  ::Sys::Io::FileOutput.new(STDERR)
end

.stdoutObject



64
65
66
# File 'lib/lib/hx_sys.rb', line 64

def HxSys.stdout 
  ::Sys::Io::FileOutput.new(STDOUT)
end