Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
Gem::NameTuple.from_list
from_list(list)
lib/rubygems/name_tuple.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/rubygems/name_tuple.rb, line 29
def self.from_list(list)
list.map do |tuple|
case tuple
when Gem::NameTuple
tuple
when Array
case tuple.length
when 3, 5
new(tuple[0], tuple[1], tuple[2], content_address: tuple[3], ruby_abi: tuple[4])
else
raise ArgumentError, "Expected a 3- or 5-element tuple, got #{tuple.length}"
end
else
raise ArgumentError, "Expected a Gem::NameTuple or Array, got #{tuple.class}"
end
end
end
Turn an array of tuples into an array of NameTuple objects. Accepts:
-
Gem::NameTupleobjects (passed through as-is) -
3-element arrays: [name, version, platform]
-
5-element arrays: [name, version, platform,
content_address,ruby_abi]