Class: Gloss::Source
- Inherits:
-
String
- Object
- String
- Gloss::Source
- Defined in:
- lib/gloss/source.rb
Instance Method Summary collapse
- #decrement_indent ⇒ Object
- #increment_indent ⇒ Object
-
#initialize(indent_level) ⇒ Source
constructor
A new instance of Source.
- #write(*args) ⇒ Object
- #write_indnt(*args) ⇒ Object
- #write_ln(*args) ⇒ Object
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_indent ⇒ Object
30 31 32 |
# File 'lib/gloss/source.rb', line 30 def decrement_indent() @indent_level -= 1 end |
#increment_indent ⇒ Object
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 |