Class: Epuber::Book::FileRequest

Inherits:
Object
  • Object
show all
Defined in:
lib/epuber/book/file_request.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_pattern, only_one: true, group: nil, properties: []) ⇒ FileRequest

Returns a new instance of FileRequest.

Parameters:

  • source_pattern (String)

    pattern describing path to file

  • only_one (Bool) (defaults to: true)

    find only one file, otherwise look for all files matching pattern in project

  • group (Symbol) (defaults to: nil)

    group of file, see Epuber::Compiler::FileFinder::GROUP_EXTENSIONS

  • properties (Array<Symbol>, Set<Symbol>) (defaults to: [])

    list of properties



32
33
34
35
36
37
# File 'lib/epuber/book/file_request.rb', line 32

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

Instance Attribute Details

#groupSymbol

Returns:

  • (Symbol)


12
13
14
# File 'lib/epuber/book/file_request.rb', line 12

def group
  @group
end

#only_oneBool

When looking for file, the resulted list should contain only one file

Default: true

Returns:

  • (Bool)


20
21
22
# File 'lib/epuber/book/file_request.rb', line 20

def only_one
  @only_one
end

#propertiesSet<String>

Returns:

  • (Set<String>)


24
25
26
# File 'lib/epuber/book/file_request.rb', line 24

def properties
  @properties
end

#source_patternString

Returns:

  • (String)


8
9
10
# File 'lib/epuber/book/file_request.rb', line 8

def source_pattern
  @source_pattern
end

Instance Method Details

#==(other) ⇒ Object

Parameters:

  • other (String, self)


53
54
55
56
57
58
59
# File 'lib/epuber/book/file_request.rb', line 53

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

#eql?(other) ⇒ Bool

Returns:

  • (Bool)


41
42
43
# File 'lib/epuber/book/file_request.rb', line 41

def eql?(other)
  self == other
end

#hashNumeric

Returns:

  • (Numeric)


47
48
49
# File 'lib/epuber/book/file_request.rb', line 47

def hash
  [@source_pattern, @group, @only_one].hash
end

#to_sString

Returns:

  • (String)


63
64
65
# File 'lib/epuber/book/file_request.rb', line 63

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