Class: Array

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

Overview

Standard Ruby class extensions

Instance Method Summary collapse

Instance Method Details

#get(*indexes) ⇒ Object

Returns multiple values of array

Parameters:

  • indexes (Array)
    • Collection of indexes


90
91
92
93
94
# File 'lib/std++/main.rb', line 90

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

#to_symObject

Returns Array values converted to Symbol



77
78
79
80
81
# File 'lib/std++/main.rb', line 77

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

#to_sym!Object

Converts Array values to Symbol



83
84
85
86
87
# File 'lib/std++/main.rb', line 83

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

#without(*vals) ⇒ Object

Returns Array values without values under given indexes



96
97
98
99
100
101
102
# File 'lib/std++/main.rb', line 96

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