Sha256: cd85d4371413b2025e2cd038dae6165c7b58a15c545d712f2139bbf88527c906

Contents?: true

Size: 364 Bytes

Versions: 11

Compression:

Stored size: 364 Bytes

Contents

module FastHaml
  module ParserUtils
    module_function

    def balance(scanner, start, finish, depth = 1)
      re = /(#{Regexp.escape(start)}|#{Regexp.escape(finish)})/
      while depth > 0 && scanner.scan_until(re)
        if scanner.matched == start
          depth += 1
        else
          depth -= 1
        end
      end
      depth
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
fast_haml-0.1.10 lib/fast_haml/parser_utils.rb
fast_haml-0.1.9 lib/fast_haml/parser_utils.rb
fast_haml-0.1.8 lib/fast_haml/parser_utils.rb
fast_haml-0.1.7 lib/fast_haml/parser_utils.rb
fast_haml-0.1.6 lib/fast_haml/parser_utils.rb
fast_haml-0.1.5 lib/fast_haml/parser_utils.rb
fast_haml-0.1.4 lib/fast_haml/parser_utils.rb
fast_haml-0.1.3 lib/fast_haml/parser_utils.rb
fast_haml-0.1.2 lib/fast_haml/parser_utils.rb
fast_haml-0.1.1 lib/fast_haml/parser_utils.rb
fast_haml-0.1.0 lib/fast_haml/parser_utils.rb