Sha256: 5373dfa2d1055e6894b51c44ca78249c50bb483d1396dd6dfda13c8e0bb12475
Contents?: true
Size: 724 Bytes
Versions: 1
Compression:
Stored size: 724 Bytes
Contents
module Geometer class Dimensions < Struct.new(:width, :height) def inspect "#{width}x#{height}" end def contains?(position) x,y=*position x_range.include?(x) && y_range.include?(y) end def sample x,y = x_range.to_a.sample, y_range.to_a.sample coord(x,y) end def area x_range.size * y_range.size end def x_range 0..(width-1) end def y_range 0..(height-1) end def all_locations @all_locations ||= assemble_all_locations end def assemble_all_locations locs = [] x_range.each do |x| y_range.each do |y| locs.push coord(x,y) end end locs end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
geometer-0.1.0 | lib/geometer/dimensions.rb |