Class: Erector::Indenting

Inherits:
Treetop::Runtime::SyntaxNode
  • Object
show all
Defined in:
lib/erector/erect/indenting.rb

Overview

:nodoc:

Constant Summary collapse

@@indent =
0

Instance Method Summary collapse

Instance Method Details

#indentObject



13
14
15
# File 'lib/erector/erect/indenting.rb', line 13

def indent
  [0, @@indent].max
end

#indented(s) ⇒ Object



17
18
19
# File 'lib/erector/erect/indenting.rb', line 17

def indented(s)
  "  " * indent + s + "\n"
end

#line(s) ⇒ Object



21
22
23
# File 'lib/erector/erect/indenting.rb', line 21

def line(s)
  indented(s)
end

#line_in(s) ⇒ Object



25
26
27
28
29
# File 'lib/erector/erect/indenting.rb', line 25

def line_in(s)
  s = indented(s)
  @@indent += 1
  s
end

#line_out(s) ⇒ Object



31
32
33
34
# File 'lib/erector/erect/indenting.rb', line 31

def line_out(s)
  @@indent -= 1
  indented(s)
end

#set_indent(x) ⇒ Object



8
9
10
11
# File 'lib/erector/erect/indenting.rb', line 8

def set_indent(x)
  @@indent = x
  self
end