module Scruffy::Helpers::PointContainer::Array_ext

Public Instance Methods

each_point(&block) click to toggle source
# File lib/scruffy/helpers/point_container.rb, line 69
def each_point(&block)
  if is_coordinate_list?
    each{|x,y|block.call(x,y)}
  else
    size.times{|k|block.call(k,self[k])}
  end
end
is_coordinate_list?() click to toggle source
# File lib/scruffy/helpers/point_container.rb, line 62
def is_coordinate_list?
  if any? && first.is_a?(Array) && first.size == 2
    return true
  end
  return false
end
keys() click to toggle source
# File lib/scruffy/helpers/point_container.rb, line 57
def keys
  return [0,size-1] unless is_coordinate_list?
  collect { |x,y| x}
end
values() click to toggle source
# File lib/scruffy/helpers/point_container.rb, line 52
def values
  return self unless is_coordinate_list?
  collect { |x,y| y}
end