Class: LicenseFinder::CondaPackage::Identifier

Inherits:
Object
  • Object
show all
Defined in:
lib/license_finder/packages/conda_package.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, version) ⇒ Identifier

Returns a new instance of Identifier.



39
40
41
42
# File 'lib/license_finder/packages/conda_package.rb', line 39

def initialize(name, version)
  @name = name
  @version = version
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



37
38
39
# File 'lib/license_finder/packages/conda_package.rb', line 37

def name
  @name
end

#versionObject

Returns the value of attribute version.



37
38
39
# File 'lib/license_finder/packages/conda_package.rb', line 37

def version
  @version
end

Class Method Details

.from_hash(hash) ⇒ Object



44
45
46
47
48
49
50
# File 'lib/license_finder/packages/conda_package.rb', line 44

def self.from_hash(hash)
  name = hash['name']
  version = hash['version']
  return nil if name.nil? || version.nil?

  Identifier.new(name, version)
end

Instance Method Details

#<=>(other) ⇒ Object



64
65
66
67
# File 'lib/license_finder/packages/conda_package.rb', line 64

def <=>(other)
  sort_name = @name <=> other.name
  sort_name.zero? ? @version <=> other.version : sort_name
end

#==(other) ⇒ Object



52
53
54
# File 'lib/license_finder/packages/conda_package.rb', line 52

def ==(other)
  other.is_a?(Identifier) && @name == other.name && @version == other.version
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/license_finder/packages/conda_package.rb', line 56

def eql?(other)
  self == other
end

#hashObject



60
61
62
# File 'lib/license_finder/packages/conda_package.rb', line 60

def hash
  [@name, @version].hash
end

#to_sObject



69
70
71
# File 'lib/license_finder/packages/conda_package.rb', line 69

def to_s
  "#{@name} - #{@version}"
end