Sha256: 29a6e0dab6507c0ac5a30e46c471befb329f335ca13483eaab6c883ad0720a23

Contents?: true

Size: 1.66 KB

Versions: 22

Compression:

Stored size: 1.66 KB

Contents

# encoding: utf-8

module Epuber
  class Book
    class FileRequest
      # @return [String]
      #
      attr_accessor :source_pattern

      # @return [Symbol]
      #
      attr_accessor :group

      # When looking for file, the resulted list should contain only one file
      #
      # Default: true
      #
      # @return [Bool]
      #
      attr_accessor :only_one

      # @return [Set<String>]
      #
      attr_accessor :properties


      # @param [String] source_pattern pattern describing path to file
      # @param [Bool] only_one find only one file, otherwise look for all files matching pattern in project
      # @param [Symbol] group group of file, see Epuber::Compiler::FileFinder::GROUP_EXTENSIONS
      # @param [Array<Symbol>, Set<Symbol>] properties list of properties
      #
      def initialize(source_pattern, only_one = true, group: nil, properties: [])
        @source_pattern = source_pattern
        @only_one       = only_one
        @group          = group
        @properties     = properties.to_set
      end

      # @return [Bool]
      #
      def eql?(other)
        self == other
      end

      # @return [Numeric]
      #
      def hash
        @source_pattern.hash ^ @group.hash ^ @only_one.hash
      end

      # @param other [String, self]
      #
      def ==(other)
        if other.is_a?(String)
          @source_pattern == other
        else
          @source_pattern == other.source_pattern && @group == other.group && @only_one == other.only_one
        end
      end

      # @return [String]
      #
      def to_s
        "#<#{self.class} pattern:`#{@source_pattern}` group:`#{@group}` only_one:`#{@only_one}`>"
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
epuber-0.6.0 lib/epuber/book/file_request.rb
epuber-0.5.7 lib/epuber/book/file_request.rb
epuber-0.5.6 lib/epuber/book/file_request.rb
epuber-0.5.5 lib/epuber/book/file_request.rb
epuber-0.5.4 lib/epuber/book/file_request.rb
epuber-0.5.3 lib/epuber/book/file_request.rb
epuber-0.5.2 lib/epuber/book/file_request.rb
epuber-0.5.1 lib/epuber/book/file_request.rb
epuber-0.5.0 lib/epuber/book/file_request.rb
epuber-0.5.0.beta.5 lib/epuber/book/file_request.rb
epuber-0.5.0.beta.4 lib/epuber/book/file_request.rb
epuber-0.5.0.beta.3 lib/epuber/book/file_request.rb
epuber-0.5.0.beta.2 lib/epuber/book/file_request.rb
epuber-0.5.0.beta lib/epuber/book/file_request.rb
epuber-0.4.0 lib/epuber/book/file_request.rb
epuber-0.3.12 lib/epuber/book/file_request.rb
epuber-0.3.11 lib/epuber/book/file_request.rb
epuber-0.3.10 lib/epuber/book/file_request.rb
epuber-0.3.9 lib/epuber/book/file_request.rb
epuber-0.3.7 lib/epuber/book/file_request.rb