Class: HxSys

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

Class Method Summary collapse

Class Method Details

.argsObject



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

def HxSys.args 
  return ARGV
end

.command(cmd, args = nil) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/lib/sys.rb', line 35

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
  return result
end

.escape_argument(arg) ⇒ Object

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



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/lib/sys.rb', line 12

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
  return "\"" + _hx_str(arg.split("\"").join("\\\"")) + "\""
end

.stderrObject



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

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

.stdoutObject



56
57
58
# File 'lib/lib/sys.rb', line 56

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