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.
105 106 107 108 |
# File 'lib/license_finder/packages/npm_package.rb', line 105 def initialize(name, version) @name = name @version = version end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
103 104 105 |
# File 'lib/license_finder/packages/npm_package.rb', line 103 def name @name end |
#version ⇒ Object
Returns the value of attribute version.
103 104 105 |
# File 'lib/license_finder/packages/npm_package.rb', line 103 def version @version end |
Class Method Details
.from_hash(hash) ⇒ Object
110 111 112 113 114 115 116 |
# File 'lib/license_finder/packages/npm_package.rb', line 110 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
130 131 132 133 |
# File 'lib/license_finder/packages/npm_package.rb', line 130 def <=>(other) sort_name = @name <=> other.name sort_name.zero? ? @version <=> other.version : sort_name end |
#==(other) ⇒ Object
118 119 120 |
# File 'lib/license_finder/packages/npm_package.rb', line 118 def ==(other) other.is_a?(Identifier) && @name == other.name && @version == other.version end |
#eql?(other) ⇒ Boolean
122 123 124 |
# File 'lib/license_finder/packages/npm_package.rb', line 122 def eql?(other) self == other end |
#hash ⇒ Object
126 127 128 |
# File 'lib/license_finder/packages/npm_package.rb', line 126 def hash [@name, @version].hash end |
#to_s ⇒ Object
135 136 137 |
# File 'lib/license_finder/packages/npm_package.rb', line 135 def to_s "#{@name} - #{@version}" end |