module Scruffy::Helpers::PointContainer
Scruffy::Helpers::PointContainer¶ ↑
- Author
-
Mat Schaffer
- Date
-
March 22nd, 2007
Allows all standard point operations to be called on both Array and Hash
Public Class Methods
extended(point_set)
click to toggle source
# File lib/scruffy/helpers/point_container.rb, line 10 def self.extended point_set point_set.extend(const_get(point_set.class.to_s)) end
Public Instance Methods
inject_with_index(memo) { |memo, item, index| ... }
click to toggle source
# File lib/scruffy/helpers/point_container.rb, line 34 def inject_with_index memo index = 0 inject(memo) do |memo, item| ret = yield memo, item, index index = index.succ ret end end
maximum_value()
click to toggle source
# File lib/scruffy/helpers/point_container.rb, line 22 def maximum_value sortable_values.sort.last end
minimum_value()
click to toggle source
# File lib/scruffy/helpers/point_container.rb, line 26 def minimum_value sortable_values.sort.first end
sortable_values()
click to toggle source
# File lib/scruffy/helpers/point_container.rb, line 14 def sortable_values values.find_all { |v| v.respond_to? :<=> } end
sum()
click to toggle source
# File lib/scruffy/helpers/point_container.rb, line 30 def sum summable_values.inject(0) { |sum, i| sum += i } end
summable_values()
click to toggle source
# File lib/scruffy/helpers/point_container.rb, line 18 def summable_values values.find_all { |v| v.respond_to? :+ } end