Class: LicenseFinder::NpmPackage::Identifier
- Inherits:
-
Object
- Object
- LicenseFinder::NpmPackage::Identifier
- Defined in:
- lib/license_finder/packages/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.
152 153 154 155 |
# File 'lib/license_finder/packages/npm_package.rb', line 152 def initialize(name, version) @name = name @version = version end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
150 151 152 |
# File 'lib/license_finder/packages/npm_package.rb', line 150 def name @name end |
#version ⇒ Object
Returns the value of attribute version.
150 151 152 |
# File 'lib/license_finder/packages/npm_package.rb', line 150 def version @version end |
Class Method Details
.from_hash(hash) ⇒ Object
157 158 159 160 161 162 163 |
# File 'lib/license_finder/packages/npm_package.rb', line 157 def self.from_hash(hash) name = hash['name'] version = hash['version'] return nil if name.nil? || name.empty? || version.nil? || version.empty? Identifier.new(name, version) end |
Instance Method Details
#<=>(other) ⇒ Object
177 178 179 180 |
# File 'lib/license_finder/packages/npm_package.rb', line 177 def <=>(other) sort_name = @name <=> other.name sort_name.zero? ? @version <=> other.version : sort_name end |
#==(other) ⇒ Object
165 166 167 |
# File 'lib/license_finder/packages/npm_package.rb', line 165 def ==(other) other.is_a?(Identifier) && @name == other.name && @version == other.version end |
#eql?(other) ⇒ Boolean
169 170 171 |
# File 'lib/license_finder/packages/npm_package.rb', line 169 def eql?(other) self == other end |
#hash ⇒ Object
173 174 175 |
# File 'lib/license_finder/packages/npm_package.rb', line 173 def hash [@name, @version].hash end |
#to_s ⇒ Object
182 183 184 |
# File 'lib/license_finder/packages/npm_package.rb', line 182 def to_s "#{@name} - #{@version}" end |