Class: Kuby::Dependable

Inherits:
Object
  • Object
show all
Defined in:
lib/kuby/dependable.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, version_or_callable) ⇒ Dependable

Returns a new instance of Dependable.



5
6
7
8
# File 'lib/kuby/dependable.rb', line 5

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/kuby/dependable.rb', line 3

def name
  @name
end

#version_or_callableObject (readonly)

Returns the value of attribute version_or_callable.



3
4
5
# File 'lib/kuby/dependable.rb', line 3

def version_or_callable
  @version_or_callable
end

Instance Method Details

#versionObject



10
11
12
13
14
15
16
17
18
# File 'lib/kuby/dependable.rb', line 10

def version
  @version ||= Kuby::Utils::SemVer.parse_version(
    if version_or_callable.respond_to?(:call)
      version_or_callable.call
    else
      version_or_callable
    end
  )
end