Sha256: 34a979e230e969c0a4f12caae33c298b9725618754807eda73f3217e863bd95d

Contents?: true

Size: 634 Bytes

Versions: 2

Compression:

Stored size: 634 Bytes

Contents

# Copyright (c) 2020 Jerome Arbez-Gindre
# frozen_string_literal: true

module DefMastership
  # Allow to know if we need to parse the line or simply ignore it
  class ParsingState
    def initialize
      @last_disabling_line = nil
    end

    def enabled?(line)
      return false if line.match(DMRegexp::SINGLE_LINE_COMMENT)

      line = line.dup.chomp
      if ['....', '----', '////'].include?(line)
        if @last_disabling_line == line
          @last_disabling_line = nil
        elsif @last_disabling_line.nil?
          @last_disabling_line = line
        end
      end
      @last_disabling_line.nil?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
defmastership-1.0.17 lib/defmastership/parsing_state.rb
defmastership-1.0.16 lib/defmastership/parsing_state.rb