Sha256: ced036a71470eb49124777f6f718161bb1b326ab07abbda0fa2782db3ae48379
Contents?: true
Size: 697 Bytes
Versions: 1
Compression:
Stored size: 697 Bytes
Contents
module Straightedge # TODO the idea is that a figure is a collection of lines and marks class Figure extend Forwardable def_delegators :marks, :each, :sample, :flatten, :to_a, :include? def_delegator :compass, :project attr_reader :lines, :marks attr_reader :compass def initialize(marks=[], lines: [], compass: Compass.default) @marks = marks @lines = lines @compass = compass end def adjacent @marks.map(&method(:project)).flatten(1).uniq.reject(&method(:include?)) end def center [@marks.map(&:x).mean, @marks.map(&:y).mean] end def distance_from_center(xy) Ruler.distance(xy,center) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
straightedge-0.1.0 | lib/straightedge/figure.rb |