Class: Gloss::Source

Inherits:
String
  • Object
show all
Defined in:
lib/gloss/source.rb

Instance Method Summary collapse

Constructor Details

#initialize(indent_level) ⇒ Source

Returns a new instance of Source.



8
9
10
11
# File 'lib/gloss/source.rb', line 8

def initialize(indent_level)
  @indent_level = indent_level
  super()
end

Instance Method Details

#decrement_indentObject



31
32
33
# File 'lib/gloss/source.rb', line 31

def decrement_indent()
  @indent_level -= 1
end

#increment_indentObject



28
29
30
# File 'lib/gloss/source.rb', line 28

def increment_indent()
  @indent_level += 1
end

#write(*args) ⇒ Object



12
13
14
15
16
17
# File 'lib/gloss/source.rb', line 12

def write(*args)
  args.each() { |a|
    self.<<(a)
  }
self
end

#write_indnt(*args) ⇒ Object



18
19
20
21
# File 'lib/gloss/source.rb', line 18

def write_indnt(*args)
  write(*args.map() { |a|
"#{"  ".*(@indent_level)}#{a}"      })
end

#write_ln(*args) ⇒ Object



22
23
24
25
26
27
# File 'lib/gloss/source.rb', line 22

def write_ln(*args)
  write_indnt(*args.map() { |a|
    a.strip
.<<("\n")
  })
end