Class: LicenseFinder::NpmPackage::Identifier
- Inherits:
-
Object
- Object
- LicenseFinder::NpmPackage::Identifier
- Defined in:
- lib/license_finder/package_managers/npm_package.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name, version) ⇒ Identifier
constructor
A new instance of Identifier.
- #to_s ⇒ Object
Constructor Details
#initialize(name, version) ⇒ Identifier
Returns a new instance of Identifier.
89 90 91 92 |
# File 'lib/license_finder/package_managers/npm_package.rb', line 89 def initialize(name, version) @name = name @version = version end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
87 88 89 |
# File 'lib/license_finder/package_managers/npm_package.rb', line 87 def name @name end |
#version ⇒ Object
Returns the value of attribute version.
87 88 89 |
# File 'lib/license_finder/package_managers/npm_package.rb', line 87 def version @version end |
Class Method Details
.from_hash(hash) ⇒ Object
94 95 96 97 98 |
# File 'lib/license_finder/package_managers/npm_package.rb', line 94 def self.from_hash(hash) name = hash['name'] || '' version = hash['version'] || '' Identifier.new(name, version) end |
Instance Method Details
#<=>(other) ⇒ Object
112 113 114 115 |
# File 'lib/license_finder/package_managers/npm_package.rb', line 112 def <=>(other) sort_name = @name <=> other.name sort_name.zero? ? @version <=> other.version : sort_name end |
#==(other) ⇒ Object
100 101 102 |
# File 'lib/license_finder/package_managers/npm_package.rb', line 100 def ==(other) other.is_a?(Identifier) && @name == other.name && @version == other.version end |
#eql?(other) ⇒ Boolean
104 105 106 |
# File 'lib/license_finder/package_managers/npm_package.rb', line 104 def eql?(other) self == other end |
#hash ⇒ Object
108 109 110 |
# File 'lib/license_finder/package_managers/npm_package.rb', line 108 def hash [@name, @version].hash end |
#to_s ⇒ Object
117 118 119 |
# File 'lib/license_finder/package_managers/npm_package.rb', line 117 def to_s "#{@name} - #{@version}" end |