Class: Array

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

Instance Method Summary collapse

Instance Method Details

#flatten_one_level ⇒ Object



540
541
542
# File 'lib/sup/util.rb', line 540

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

#last=(e) ⇒ Object



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

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

#nonempty? ⇒ Boolean

Returns:

  • (Boolean)


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

def nonempty?; !empty? end

#rest ⇒ Object



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

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

#to_boolean_h ⇒ Object



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

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

#to_h ⇒ Object



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

def to_h; Hash[*flatten_one_level]; end