Sha256: eb6fba3bc02cd1754bdeed6e2f3b67abd60be7df803a95064b7e4a873727d815

Contents?: true

Size: 854 Bytes

Versions: 1

Compression:

Stored size: 854 Bytes

Contents

require 'is/area'
require 'is/point'

class Is

  class << self

    def point(point)
      Point.new *point
    end

    def all_points(points)
      pts = points.map { |it| Point.new *it }

      pts.define_singleton_method :in?, ->(area) do
        area = Area.new area
        all? { |point| point.in? area }
      end

      pts
    end
    alias :points :all_points

    def any_points(points)
      pts = points.map { |it| Point.new *it }

      pts.define_singleton_method :in?, ->(area) do
        area = Area.new area
        any? { |point| 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

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
is-0.0.1 lib/is.rb