Module: Indentation
- Included in:
- JsonNodeFormatter, Node, Nodifier, XmlNodeFormatter
- Defined in:
- lib/indentation.rb
Instance Method Summary collapse
Instance Method Details
#indent(content, indent_level = 1) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/indentation.rb', line 16 def indent(content, indent_level = 1) output = '' content.lines do |line| output << (' ' * indent_level) + line end output end |
#unindent(content) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/indentation.rb', line 3 def unindent(content) output = '' first_line = content.lines.first leading_spaces = first_line.length - first_line.lstrip.length content.lines do |line| output << line[leading_spaces..-1] || '' end output end |