Sha256: 17d2de3c88ce1e191a5b56e5e67524c3aa26fd854e40d00c571f5b24af512db8

Contents?: true

Size: 1.03 KB

Versions: 149

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

require 'eac_fs/traverser'

module EacFs
  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(::EacFs::Traversable.prop_method_name(method)) do |_path|
        nil
      end
    end

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

      define_method("#{::EacFs::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 = ::EacFs::Traverser.new
      (BOOLEAN_PROPS + PATH_PROPS).each do |prop|
        r.send("#{prop}=", method(::EacFs::Traversable.prop_method_name(prop)))
      end
      r
    end
  end
end

Version data entries

149 entries across 149 versions & 4 rubygems

Version Path
eac_fs-0.18.1 lib/eac_fs/traversable.rb
eac_fs-0.18.0 lib/eac_fs/traversable.rb
eac_fs-0.17.0 lib/eac_fs/traversable.rb
eac_tools-0.76.0 sub/eac_fs/lib/eac_fs/traversable.rb
eac_tools-0.75.2 sub/eac_fs/lib/eac_fs/traversable.rb
eac_tools-0.75.1 sub/eac_fs/lib/eac_fs/traversable.rb
eac_tools-0.75.0 sub/eac_fs/lib/eac_fs/traversable.rb
eac_tools-0.74.1 sub/eac_fs/lib/eac_fs/traversable.rb
eac_tools-0.74.0 sub/eac_fs/lib/eac_fs/traversable.rb
eac_tools-0.73.0 sub/eac_fs/lib/eac_fs/traversable.rb
eac_tools-0.72.0 sub/eac_fs/lib/eac_fs/traversable.rb
eac_tools-0.70.1 sub/eac_fs/lib/eac_fs/traversable.rb
eac_tools-0.70.0 sub/eac_fs/lib/eac_fs/traversable.rb
eac_tools-0.69.1 sub/eac_fs/lib/eac_fs/traversable.rb
eac_tools-0.69.0 sub/eac_fs/lib/eac_fs/traversable.rb
eac_tools-0.68.0 sub/eac_fs/lib/eac_fs/traversable.rb
eac_tools-0.67.1 sub/eac_fs/lib/eac_fs/traversable.rb
eac_tools-0.67.0 sub/eac_fs/lib/eac_fs/traversable.rb
eac_tools-0.66.0 sub/eac_fs/lib/eac_fs/traversable.rb
eac_tools-0.65.1 sub/eac_fs/lib/eac_fs/traversable.rb