Sha256: e74512c9345b7ff6913c979ac990d0b94efbe5872fa65208bdadaeca5e1b1341

Contents?: true

Size: 745 Bytes

Versions: 4

Compression:

Stored size: 745 Bytes

Contents

# frozen_string_literal: true

module Leftovers
  class DefinitionToAdd
    attr_reader :node, :name, :location

    def initialize(node, name: node.name, location: node.loc.name)
      @node = node
      @name = name
      @location = location
    end

    def privacy=(value)
      @node.privacy = value
    end

    def keep?(file_collector)
      @keep ||= file_collector.keep_line?(location.line) || ::Leftovers.config.keep === node
    end

    def test?(file_collector)
      file_collector.test_line?(location.line) || ::Leftovers.config.test_only === node
    end

    def to_definition(file_collector)
      return if keep?(file_collector)

      Definition.new(name, location: location, test: test?(file_collector))
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
leftovers-0.12.2 lib/leftovers/definition_to_add.rb
leftovers-0.12.1 lib/leftovers/definition_to_add.rb
leftovers-0.12.0 lib/leftovers/definition_to_add.rb
leftovers-0.11.2 lib/leftovers/definition_to_add.rb