Sha256: 210a24cafab2d86c003efb2b94f54b5e49dc4959854e4beefb8abd777bcab56e

Contents?: true

Size: 1.66 KB

Versions: 9

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

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, @group, @only_one].hash
      end

      # @param [String, self] other
      #
      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

9 entries across 9 versions & 1 rubygems

Version Path
epuber-0.11.1 lib/epuber/book/file_request.rb
epuber-0.11.0 lib/epuber/book/file_request.rb
epuber-0.10.3 lib/epuber/book/file_request.rb
epuber-0.10.2 lib/epuber/book/file_request.rb
epuber-0.10.1 lib/epuber/book/file_request.rb
epuber-0.9.3 lib/epuber/book/file_request.rb
epuber-0.9.2 lib/epuber/book/file_request.rb
epuber-0.9.1 lib/epuber/book/file_request.rb
epuber-0.9.0 lib/epuber/book/file_request.rb