Sha256: c5e6960301cc806b25435c3cb3b9e482ea542bc9cb8cb162d8a0079fd6a69c2e

Contents?: true

Size: 1.18 KB

Versions: 189

Compression:

Stored size: 1.18 KB

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/fs/traverser'

module EacRubyUtils
  module Fs
    module Traversable
      PROP_METHOD_PREFIX = 'traverser_'
      BOOLEAN_PROPS = %i[hidden_directories recursive sort].freeze
      PATH_PROPS = %i[check_directory check_file].freeze

      class << self
        def prop_method_name(prop)
          "#{PROP_METHOD_PREFIX}#{prop}"
        end
      end

      PATH_PROPS.each do |method|
        define_method(::EacRubyUtils::Fs::Traversable.prop_method_name(method)) do |_path|
          nil
        end
      end

      BOOLEAN_PROPS.each do |method|
        define_method(::EacRubyUtils::Fs::Traversable.prop_method_name(method)) do
          false
        end

        define_method("#{::EacRubyUtils::Fs::Traversable.prop_method_name(method)}?") do
          send(method_name)
        end
      end

      def traverser_check_path(path)
        traverser_new.check_path(path)
      end

      def traverser_new
        r = ::EacRubyUtils::Fs::Traverser.new
        (BOOLEAN_PROPS + PATH_PROPS).each do |prop|
          r.send("#{prop}=", method(::EacRubyUtils::Fs::Traversable.prop_method_name(prop)))
        end
        r
      end
    end
  end
end

Version data entries

189 entries across 189 versions & 3 rubygems

Version Path
eac_ruby_utils-0.78.0 lib/eac_ruby_utils/fs/traversable.rb
avm-tools-0.110.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb
eac_ruby_utils-0.77.1 lib/eac_ruby_utils/fs/traversable.rb
avm-tools-0.109.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb
eac_ruby_utils-0.77.0 lib/eac_ruby_utils/fs/traversable.rb
avm-tools-0.109.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb
ehbrs-tools-0.28.2 vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb
avm-tools-0.108.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb
ehbrs-tools-0.28.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb
avm-tools-0.107.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb
eac_ruby_utils-0.76.0 lib/eac_ruby_utils/fs/traversable.rb
ehbrs-tools-0.28.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb
avm-tools-0.106.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb
ehbrs-tools-0.27.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb
eac_ruby_utils-0.75.0 lib/eac_ruby_utils/fs/traversable.rb
ehbrs-tools-0.26.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb
avm-tools-0.105.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb
ehbrs-tools-0.25.1 vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb
ehbrs-tools-0.25.0 vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traversable.rb
eac_ruby_utils-0.74.0 lib/eac_ruby_utils/fs/traversable.rb