Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/std++/main.rb

Overview

Standard Ruby class extensions

Dev Tools collapse

Instance Method Details

#get(*indexes) ⇒ Object

Returns multiple values of array

Parameters:

  • indexes (Array)
    • Collection of indexes



100
101
102
103
104
# File 'lib/std++/main.rb', line 100

def get *indexes
    indexes.collect do | index |
        self[index]
    end
end

#to_symObject

Returns Array values converted to Symbol



87
88
89
90
91
# File 'lib/std++/main.rb', line 87

def to_sym
    self.map do | el |
        el.to_sym
    end
end

#to_sym!Object

Converts Array values to Symbol



93
94
95
96
97
# File 'lib/std++/main.rb', line 93

def to_sym!
    self.map! do | el |
        el.to_sym
    end
end

#without(*vals) ⇒ Object

Returns Array values without values under given indexes



106
107
108
109
110
111
112
# File 'lib/std++/main.rb', line 106

def without(*vals)
    cpy = self.dup
    vals.each do | val |
        cpy.delete(val) 
    end
    cpy
end