Class: Mj::AlternativeFile::Candidate

Inherits:
Object
  • Object
show all
Defined in:
lib/mj/alternative_file/candidate.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, type:, metadata: {}) ⇒ Candidate

Returns a new instance of Candidate.



9
10
11
12
13
# File 'lib/mj/alternative_file/candidate.rb', line 9

def initialize(path:, type:, metadata: {})
  @path = path
  @type = type
  @metadata =  || {}
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



6
7
8
# File 'lib/mj/alternative_file/candidate.rb', line 6

def path
  @path
end

#typeObject (readonly)

Returns the value of attribute type.



7
8
9
# File 'lib/mj/alternative_file/candidate.rb', line 7

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



19
20
21
22
23
24
25
# File 'lib/mj/alternative_file/candidate.rb', line 19

def ==(other)
  unless other.is_a?(self.class)
    return false
  end

  other.path == path && other.type == type
end

#exist?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/mj/alternative_file/candidate.rb', line 15

def exist?
  File.exist?(path)
end

#inspectObject



27
28
29
# File 'lib/mj/alternative_file/candidate.rb', line 27

def inspect
  "#{path}|#{type}"
end

#to_s(debug: false) ⇒ Object



31
32
33
34
35
36
37
38
39
# File 'lib/mj/alternative_file/candidate.rb', line 31

def to_s(debug: false)
  parts = [path]

  if debug
    parts.push("(#{})")
  end

  parts.join
end