Sha256: b5d81e3413d1636a12c04de344a31692fb5c9486cb7d82be3a95db9fbdc26a9d
Contents?: true
Size: 557 Bytes
Versions: 2
Compression:
Stored size: 557 Bytes
Contents
# Copyright (c) 2008 Michael Fellinger m.fellinger@gmail.com # All files in this distribution are subject to the terms of the Ruby license. # Extensions for Struct class Struct # Example: # Point = Struct.new(:x, :y) # point = Point.new(15, 10) # point.values_at(:y, :x) # # => [10, 15] # point.values_at(0, 1) # # => [15, 10] def values_at(*keys) if keys.all?{|key| key.respond_to?(:to_int) and not key.is_a?(Symbol) } keys.map{|key| values[key.to_int] } else keys.map{|k| self[k] } end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ramaze-0.3.9 | lib/ramaze/snippets/struct/values_at.rb |
ramaze-0.3.9.1 | lib/ramaze/snippets/struct/values_at.rb |