Class: Mj::AlternativeFile::Candidate
- Inherits:
-
Object
- Object
- Mj::AlternativeFile::Candidate
- Defined in:
- lib/mj/alternative_file/candidate.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #exist? ⇒ Boolean
-
#initialize(path:, type:, metadata: {}) ⇒ Candidate
constructor
A new instance of Candidate.
- #inspect ⇒ Object
- #to_s(debug: false) ⇒ Object
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
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/mj/alternative_file/candidate.rb', line 6 def path @path end |
#type ⇒ Object (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
15 16 17 |
# File 'lib/mj/alternative_file/candidate.rb', line 15 def exist? File.exist?(path) end |
#inspect ⇒ Object
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 |