File: PrintFile.rb

package info (click to toggle)
quickfix 1.13.3%2Bdfsg-9
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 152,548 kB
  • ctags: 679,426
  • sloc: cpp: 639,331; xml: 129,200; python: 108,722; ruby: 85,152; sh: 10,492; ansic: 9,025; java: 1,827; cs: 1,145; makefile: 523; sql: 313; perl: 108
file content (63 lines) | stat: -rw-r--r-- 889 bytes parent folder | download
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
class PrintFile
  def initialize(name)
    @depth = 0
    @name = name
    @file = createFile(name)
  end

  def createFile(name)
    attr = File::CREAT|File::TRUNC|File::RDWR
    File.new(name, attr, 0644)
  end

  def tabs
    return "" if @depth == 0
    count = 0
    result = ""
    while (count != @depth)
      result += "  " 
      count += 1
    end
    return result
  end

  def indent
    @depth += 1
  end

  def dedent
    return if @depth == 0
    @depth -= 1
  end

  def printInline(*values)
    @file.print values
  end

  def putsInline(*values)
    @file.puts(values)
  end

  def print(*values)
    if(values.length == 0)
      return
    end

    @file.print tabs
    @file.print values
  end

  def puts(*values)
    if(values.length == 0)
      @file.puts
      return
    end

    @file.print tabs
    @file.puts values
  end

  def close
    @file.close
  end
end