Class: Prof::Product
- Inherits:
-
Object
show all
- Defined in:
- lib/prof/product.rb
Defined Under Namespace
Classes: InvalidProductPathError
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(path:) ⇒ Product
Returns a new instance of Product.
20
21
22
23
|
# File 'lib/prof/product.rb', line 20
def initialize(path:)
raise InvalidProductPathError, "Invalid path given: '#{path}'" unless path && File.exist?(path)
@path = File.expand_path(path)
end
|
Instance Attribute Details
#path ⇒ Object
Returns the value of attribute path.
18
19
20
|
# File 'lib/prof/product.rb', line 18
def path
@path
end
|
Instance Method Details
#==(other) ⇒ Object
Also known as:
eql?
41
42
43
44
|
# File 'lib/prof/product.rb', line 41
def ==(other)
self.class == other.class &&
self.path == other.path
end
|
#file ⇒ Object
37
38
39
|
# File 'lib/prof/product.rb', line 37
def file
File.open(path)
end
|
#name ⇒ Object
25
26
27
|
# File 'lib/prof/product.rb', line 25
def name
metadata.fetch('name')
end
|
#to_s ⇒ Object
33
34
35
|
# File 'lib/prof/product.rb', line 33
def to_s
"#{name} v#{version}"
end
|
#version ⇒ Object
29
30
31
|
# File 'lib/prof/product.rb', line 29
def version
metadata.fetch('product_version')
end
|