Class: Bosh::Cli::GlobMatch

Inherits:
Object show all
Defined in:
lib/cli/glob_match.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dir, path) ⇒ GlobMatch

Returns a new instance of GlobMatch.



9
10
11
12
# File 'lib/cli/glob_match.rb', line 9

def initialize(dir, path)
  @dir = dir
  @path = path
end

Instance Attribute Details

#dirObject (readonly)

Helper class encapsulating the data we know about the glob. We need both directory and file path, as we match the same path in several directories (src, src_alt, blobs)



6
7
8
# File 'lib/cli/glob_match.rb', line 6

def dir
  @dir
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/cli/glob_match.rb', line 7

def path
  @path
end

Instance Method Details

#<=>(other) ⇒ Object



18
19
20
# File 'lib/cli/glob_match.rb', line 18

def <=>(other)
  @path <=> other.path
end

#eql?(other) ⇒ Boolean

GlobMatch will be used as Hash key (as implied by using Set), hence we need to define both eql? and hash

Returns:

  • (Boolean)


24
25
26
# File 'lib/cli/glob_match.rb', line 24

def eql?(other)
  @path == other.path
end

#full_pathObject



14
15
16
# File 'lib/cli/glob_match.rb', line 14

def full_path
  File.join(dir, path)
end

#hashObject



28
29
30
# File 'lib/cli/glob_match.rb', line 28

def hash
  @path.hash
end