Class: Prof::Product

Inherits:
Object
  • 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

#pathObject (readonly)

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

#fileObject



37
38
39
# File 'lib/prof/product.rb', line 37

def file
  File.open(path)
end

#nameObject



25
26
27
# File 'lib/prof/product.rb', line 25

def name
  .fetch('name')
end

#to_sObject



33
34
35
# File 'lib/prof/product.rb', line 33

def to_s
  "#{name} v#{version}"
end

#versionObject



29
30
31
# File 'lib/prof/product.rb', line 29

def version
  .fetch('product_version')
end