Sha256: 9698a9aa84431425fb71d12801d545abe62125802d8bc56776e93fdaf30eb2b5

Contents?: true

Size: 749 Bytes

Versions: 16

Compression:

Stored size: 749 Bytes

Contents

module SandiMeter
  class MethodArgumentsCounter
    def initialize
      reset!
    end

    def count(args_add_block_sexp)
      reset!

      @count += args_add_block_sexp[1].size
      @count += 1 if args_add_block_sexp.last == true
      bypass_sexp(args_add_block_sexp)

      return [@count, @lines.uniq.sort.first]
    end

    def reset!
      @count = 0
      @lines = []
    end

    private
    def bypass_sexp(args_add_block_sexp)
      args_add_block_sexp.each do |sexp|
        next unless sexp.kind_of?(Array)

        case sexp.first
        when :bare_assoc_hash
          @count += sexp[1].size - 1
        when :@int, :@ident
          @lines << sexp.last.first
        end

        bypass_sexp(sexp)
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
sandi_meter-1.2.0 lib/sandi_meter/method_arguments_counter.rb
sandi_meter-1.1.8 lib/sandi_meter/method_arguments_counter.rb
sandi_meter-1.1.7 lib/sandi_meter/method_arguments_counter.rb
sandi_meter-1.1.6 lib/sandi_meter/method_arguments_counter.rb
sandi_meter-1.1.5 lib/sandi_meter/method_arguments_counter.rb
sandi_meter-1.0.5 lib/sandi_meter/method_arguments_counter.rb
sandi_meter-1.0.4 lib/sandi_meter/method_arguments_counter.rb
sandi_meter-1.0.3 lib/sandi_meter/method_arguments_counter.rb
sandi_meter-1.0.2 lib/sandi_meter/method_arguments_counter.rb
sandi_meter-1.0.1 lib/sandi_meter/method_arguments_counter.rb
sandi_meter-1.0.0 lib/sandi_meter/method_arguments_counter.rb
sandi_meter-0.0.6 lib/sandi_meter/method_arguments_counter.rb
sandi_meter-0.0.5 lib/sandi_meter/method_arguments_counter.rb
sandi_meter-0.0.4 lib/sandi_meter/method_arguments_counter.rb
sandi_meter-0.0.3 lib/sandi_meter/method_arguments_counter.rb
sandi_meter-0.0.2 lib/sandi_meter/method_arguments_counter.rb