Sha256: c23d0752743aeb4755fc1b5bcd62fc100e33250f58bb1d2d170d32a1e086f910

Contents?: true

Size: 643 Bytes

Versions: 1

Compression:

Stored size: 643 Bytes

Contents

require File.expand_path('../../../templates/range_exclusive', __FILE__)

class Exercism
  module Analyzers

    class Range < Analyzer

      processor Processors::RangeProcessor

      def call
        feedback = processor.result.map do |range_exp|
          if range_exp.inclusive? && decrement_one?(range_exp.right)
            Feedback.from_src(:range, range_exp.src_extract, Templates::RangeExclusive.render(range_exp))
          end
        end.compact
        Result.new(:range_inclusive, feedback)
      end

      private

      def decrement_one?(exp)
        exp.value == '-' && exp.right.value == '1'
      end

    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
exercism-analysis-0.1.1 lib/exercism-analysis/analyzers/ruby/range.rb