Class: Array

Inherits:
Object show all
Defined in:
lib/sup/util.rb

Instance Method Summary collapse

Instance Method Details

#flatten_one_levelObject



562
563
564
# File 'lib/sup/util.rb', line 562

def flatten_one_level
  inject([]) { |a, e| a + e }
end

#last=(e) ⇒ Object



571
# File 'lib/sup/util.rb', line 571

def last= e; self[-1] = e end

#nonempty?Boolean

Returns:

  • (Boolean)


572
# File 'lib/sup/util.rb', line 572

def nonempty?; !empty? end

#restObject



567
# File 'lib/sup/util.rb', line 567

def rest; self[1..-1]; end

#to_boolean_hObject



569
# File 'lib/sup/util.rb', line 569

def to_boolean_h; Hash[*map { |x| [x, true] }.flatten]; end

#to_hObject



566
# File 'lib/sup/util.rb', line 566

def to_h; Hash[*flatten]; end