smalruby/smalruby-editor

View on GitHub
app/models/concerns/ruby_to_block/block/sensing_reach_wall.rb

Summary

Maintainability
A
55 mins
Test Coverage
# -*- coding: utf-8 -*-
module RubyToBlock
  module Block
    class SensingReachWall < Value
      include CharacterOperation

      blocknize '^\s*' + CHAR_RE + 'reach_wall\?\s*$',
                value: true

      def self.process_match_data(md, context)
        md2 = regexp.match(md[type])

        character = get_character(context, md2[1])
        return false if context.receiver != character

        block = new
        context.add_value(block)
        block.character = character

        true
      end
    end
  end
end