class Array

Public Instance Methods

*(rhs=nil) click to toggle source
# File lib/hobo_support/array.rb, line 5
def *(rhs=nil)
  if rhs
    multiply(rhs)
  else
    Enumerable::MultiSender.new(self, :map)
  end
end
Also aliased as: multiply
drop_while!() { |self| ... } click to toggle source
# File lib/hobo_support/array.rb, line 13
def drop_while!
  drop = 0
  drop += 1 while yield(self[drop])
  self[0..drop-1] = []
  self
end
multiply(rhs=nil) click to toggle source
Alias for: *
safe_join(sep=$,) click to toggle source

it always returns an html_safe? string preserving the html_safe? items and separator, excaping the rest

# File lib/hobo_support/xss.rb, line 5
def safe_join(sep=$,)
  map {|i| ERB::Util.html_escape(i)}.join(ERB::Util.html_escape(sep)).html_safe
end

Public Class Methods

wrap(object) click to toggle source
# File lib/hobo_support/array.rb, line 22
def self.wrap(object)
  case object
  when nil
    []
  when self
    object
  else
    if object.respond_to?(:to_ary)
      object.to_ary
    else
      [object]
    end
  end
end