Module: Cucumber::Core::Gherkin::Writer::Indentation

Defined in:
lib/cucumber/core/gherkin/writer/helpers.rb

Class Method Summary collapse

Class Method Details

.level(number) ⇒ Object



109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/cucumber/core/gherkin/writer/helpers.rb', line 109

def self.level(number)
  Module.new do
    define_method(:indent) do |string, amount = nil|
      return string if string.nil? || string.empty?

      amount ||= number
      "#{' ' * amount}#{string}"
    end

    define_method(:indent_level) do
      number
    end

    define_method(:prepare_statements) do |*statements|
      statements.flatten.compact.map { |s| indent(s) }
    end
  end
end