Class: Array

Inherits:
Object show all
Defined in:
lib/shorthand.rb,
lib/shorthand.rb

Instance Method Summary collapse

Instance Method Details

#avg0Object



268
# File 'lib/shorthand.rb', line 268

def avg0() _i = map{|v| v.numeric? ? v.to_f : nil}.compact; _i.size > 0 ? (_i = _i.inject(:+) / size.to_f) : 0.0 end

#compactedObject Also known as: stable_compact



266
# File 'lib/shorthand.rb', line 266

def compacted() map{|v| v.blank? ? nil : v}.compact end

#hmap(&block) ⇒ Object



269
# File 'lib/shorthand.rb', line 269

def hmap(&block) OrderedHash[*(self.each_with_index.map{|v,k| yield(k,v)}.compact.flatten)] end

#sentencesObject



265
# File 'lib/shorthand.rb', line 265

def sentences() join(' ').sentences end

#wrap(indent = :first, width = nil) ⇒ Object



264
# File 'lib/shorthand.rb', line 264

def wrap(indent=:first, width=nil) join(' ').wrap(indent, width) end