Module: Valise::StringTools
- Included in:
- DefinedDefaults::DefinitionHelper
- Defined in:
- lib/valise/utils.rb
Class Method Summary collapse
Class Method Details
.align(string) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/valise/utils.rb', line 3 def align(string) lines = string.split(/\n/) first = lines.shift match = /^(\s*)<<</.match(first) unless(match.nil?) return lines.map do |line| unless /^#{match[1]}|^\s*$/ =~ line raise Errors::UnderIndented, line end line.sub(/^#{match[1]}/, "") end.join("\n") end return string end |