Class: Doubleshot::Dependencies::Dependency

Inherits:
Object
  • Object
show all
Defined in:
lib/doubleshot/dependencies/dependency.rb

Direct Known Subclasses

GemDependency, JarDependency

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ Dependency

Returns a new instance of Dependency.



6
7
8
# File 'lib/doubleshot/dependencies/dependency.rb', line 6

def initialize(name)
  @name = name.dup.freeze
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/doubleshot/dependencies/dependency.rb', line 4

def name
  @name
end

#versionObject (readonly)

Returns the value of attribute version.



4
5
6
# File 'lib/doubleshot/dependencies/dependency.rb', line 4

def version
  @version
end

Instance Method Details

#==(other) ⇒ Object



18
19
20
# File 'lib/doubleshot/dependencies/dependency.rb', line 18

def ==(other)
  eql?(other)
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/doubleshot/dependencies/dependency.rb', line 10

def eql?(other)
  other.is_a?(self.class) and other.name == @name
end

#hashObject



14
15
16
# File 'lib/doubleshot/dependencies/dependency.rb', line 14

def hash
  @hash ||= @name.hash
end

#lock(version) ⇒ Object



22
23
24
# File 'lib/doubleshot/dependencies/dependency.rb', line 22

def lock(version)
  @version = version
end

#locked?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/doubleshot/dependencies/dependency.rb', line 26

def locked?
  !!@version
end

#to_s(long_form = false) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/doubleshot/dependencies/dependency.rb', line 30

def to_s(long_form = false)
  if long_form && @version
    "#{name} (#{@version})"
  else
    @name
  end
end