Class: Asdf::Tool

Inherits:
Object
  • Object
show all
Defined in:
lib/asdf/tool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, versions) ⇒ Tool

Returns a new instance of Tool.



8
9
10
11
# File 'lib/asdf/tool.rb', line 8

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

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/asdf/tool.rb', line 5

def name
  @name
end

#versionsObject

Returns the value of attribute versions.



6
7
8
# File 'lib/asdf/tool.rb', line 6

def versions
  @versions
end

Instance Method Details

#default_tool_versionObject



17
18
19
20
21
22
23
24
# File 'lib/asdf/tool.rb', line 17

def default_tool_version
  # tool_versions.first is in the format of the following, where we only
  # want the instance of ToolVersion:
  #
  # {"version" => Asdf::ToolVersion}
  #
  tool_versions.first[1]
end

#default_versionObject



13
14
15
# File 'lib/asdf/tool.rb', line 13

def default_version
  default_tool_version.version
end

#tool_versionsObject



26
27
28
29
30
# File 'lib/asdf/tool.rb', line 26

def tool_versions
  @tool_versions ||= versions.each_with_object({}) do |version, all|
    all[version] = ToolVersion.new(name, version)
  end
end