Sha256: 4f7ea98bf1a079effa91dda64ae0d9839cc186e8557007d803eab91bb3d30d73
Contents?: true
Size: 1016 Bytes
Versions: 14
Compression:
Stored size: 1016 Bytes
Contents
module Savage class Path require File.dirname(__FILE__) + "/direction_proxy" require File.dirname(__FILE__) + "/sub_path" include Utils include DirectionProxy attr_accessor :subpaths define_proxies do |sym,const| define_method(sym) do |*args| @subpaths.last.send(sym,*args) end end def initialize(*args) @subpaths = [SubPath.new] @subpaths.last.move_to(*args) if (2..3).include?(*args.length) yield self if block_given? end def directions directions = [] @subpaths.each { |subpath| directions.concat(subpath.directions) } directions end def move_to(*args) unless (@subpaths.last.directions.empty?) (@subpaths << SubPath.new(*args)).last else @subpaths.last.move_to(*args) end end def closed? @subpaths.last.closed? end def to_command @subpaths.collect { |subpath| subpath.to_command }.join end end end
Version data entries
14 entries across 14 versions & 1 rubygems