Class: Array

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

Instance Method Summary collapse

Instance Method Details

#flatten_one_levelObject



597
598
599
# File 'lib/sup/util.rb', line 597

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

#last=(e) ⇒ Object



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

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

#nonempty?Boolean

Returns:

  • (Boolean)


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

def nonempty?; !empty? end

#restObject



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

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

#to_boolean_hObject



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

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

#to_hObject



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

def to_h; Hash[*flatten]; end