Class: Array
Instance Method Summary collapse
- #avg0 ⇒ Object
- #compacted ⇒ Object (also: #stable_compact)
- #hmap(&block) ⇒ Object
- #sentences ⇒ Object
- #wrap(indent = :first, width = nil) ⇒ Object
Instance Method Details
#avg0 ⇒ Object
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 |
#compacted ⇒ Object 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 |
#sentences ⇒ Object
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 |