Sha256: d309f498917417e126e83f4081edc46f5646fe993c6ab433a7b570e5a9557dac
Contents?: true
Size: 1.39 KB
Versions: 1
Compression:
Stored size: 1.39 KB
Contents
require 'is/area' require 'is/point' class Is class << self def point(point) Point.new *point end def all_points(points) pts = points.clone pts.define_singleton_method :in?, ->(area) do area = Area.new area all? { |point| Point.new(*point).in? area } end pts end alias :points :all_points def any_points(points) pts = points.clone pts.define_singleton_method :in?, ->(area) do area = Area.new area any? { |point| Point.new(*point).in? area } end pts end def select(points) pts = points.clone pts.define_singleton_method :in, ->(area) do area = Area.new area select { |point| Point.new(*point).in? area } end pts end def first(points) pts = points.clone pts.define_singleton_method :in, ->(area) do area = Area.new area find { |point| Point.new(*point).in? area } end pts end def point_in_area?(point, area) point(point).in? area end def all_points_in_area?(points, area) all_points(points).in?(area) end def any_points_in_area?(points, area) any_points(points).in?(area) end def select_points_in_area(points, area) select(points).in(area) end def first_point_in_area(points, area) first(points).in(area) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
is-0.0.2 | lib/is.rb |