Class: ReeString::Indent

Inherits:
Object
  • Object
show all
Includes:
Ree::FnDSL
Defined in:
lib/ree_lib/packages/ree_string/package/ree_string/functions/indent.rb

Instance Method Summary collapse

Instance Method Details

#call(string, amount, **opts) ⇒ Object



46
47
48
49
50
# File 'lib/ree_lib/packages/ree_string/package/ree_string/functions/indent.rb', line 46

def call(string, amount, **opts)
  indent_string = opts[:indent_string] || string[/^[ \t]/] || " "
  regex = opts[:empty_lines] ? /^/ : /^(?!$)/
  string.gsub(regex, indent_string * amount)
end