Sha256: 37db903df735e8c2f507bfcd3897882dcbc7e31896ba246cadb9068f54a6e6ed

Contents?: true

Size: 653 Bytes

Versions: 50

Compression:

Stored size: 653 Bytes

Contents

# -*- coding: utf-8 -*-
module RubyToBlock
  module Block
    class End < Base
      blocknize '^\s*end\s*$', statement: true

      def self.process_match_data(md, context)
        ends_num = 1
        context.lines.each do |l|
          md2 = Block.statement_regexp.match(l)
          type = md2.names.find { |n| md2[n.to_sym] }
          if type == 'end'
            ends_num += 1
          elsif Block[type].indent?
            ends_num -= 1
          end
        end
        if context.statement && ends_num <= context.statement_stack.length
          Block.process_end(context)
        else
          false
        end
      end
    end
  end
end

Version data entries

50 entries across 50 versions & 1 rubygems

Version Path
smalruby-editor-0.4.1-x86-mingw32 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.4.2-x86-mingw32 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.4.2 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.4.1 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.4.0-x86-mingw32 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.4.0 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.3.5-x86-mingw32 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.3.5 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.3.4-x86-mingw32 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.3.4 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.3.3-x86-mingw32 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.3.3 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.3.2-x86-mingw32 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.3.2 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.3.1-x86-mingw32 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.3.1 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.3.0-x86-mingw32 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.3.0 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.2.7-x86-mingw32 app/models/concerns/ruby_to_block/block/end.rb
smalruby-editor-0.2.7 app/models/concerns/ruby_to_block/block/end.rb