class Shaf::Generator::Helper
Public Instance Methods
binding()
click to toggle source
public method mapped to Kernel's private binding
Calls superclass method
# File lib/shaf/generator/helper.rb, line 7 def binding super end
indentation(level)
click to toggle source
# File lib/shaf/generator/helper.rb, line 28 def indentation(level) ' ' * level end
Also aliased as: i
print(lines, indent_level = 2)
click to toggle source
# File lib/shaf/generator/helper.rb, line 11 def print(lines, indent_level = 2) strip_blank(lines).inject do |result, line| indent = i(indent_level) unless line.empty? result + "\n#{indent}#{line}" end.chomp end
print_nested(sections, indent_level = 2)
click to toggle source
# File lib/shaf/generator/helper.rb, line 18 def print_nested(sections, indent_level = 2) sections.map(&method(:print)).join("\n\n#{i(indent_level)}") end
strip_blank(lines)
click to toggle source
# File lib/shaf/generator/helper.rb, line 22 def strip_blank(lines) lines.map do |line| line.strip.empty? ? '' : line end end