Class: Array

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

Instance Method Summary collapse

Instance Method Details

#flatten_one_levelObject



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

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

#last=(e) ⇒ Object



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

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

#nonempty?Boolean

Returns:

  • (Boolean)


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

def nonempty?; !empty? end

#restObject



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

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

#to_boolean_hObject



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

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

#to_hObject



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

def to_h; Hash[*flatten]; end