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.



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

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

Instance Method Details

#decrement_indentObject



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

def decrement_indent()
  @indent_level -= 1
end

#increment_indentObject



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

def increment_indent()
  @indent_level += 1
end

#write(*args) ⇒ Object



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

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

#write_indnt(*args) ⇒ Object



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

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

#write_ln(*args) ⇒ Object



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

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