Module: VisiLibity
- Defined in:
- lib/visilibity.rb
Defined Under Namespace
Classes: Angle, BoundingBox, Environment, Guards, LineSegment, Point, PolarPoint, Polygon, Polyline, Ray, VisibilityGraph, VisibilityPolygon
Class Method Summary collapse
- .Inspectors(*fake_ivars) ⇒ Object
-
.SwigEnumerable(size_method = :size) ⇒ Object
Enables enumeration over Swig collections implementing size_method and index().
Class Method Details
.Inspectors(*fake_ivars) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/visilibity.rb', line 20 def self.Inspectors(*fake_ivars) Module.new do define_method :inspect do ivar_str = fake_ivars.map{|iv| "@#{iv}=#{send(iv).inspect}"}.join(" ") "#<%s:0x%x %s>" % [self.class.name, object_id, ivar_str] end end end |
.SwigEnumerable(size_method = :size) ⇒ Object
Enables enumeration over Swig collections implementing size_method and index().
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/visilibity.rb', line 8 def self.SwigEnumerable(size_method=:size) Module.new do include Enumerable # Must eval a string here because #each takes a block. Oh bother. class_eval <<-RUBY def each (0...#{size_method}).each{|i| yield self.index(i)} end RUBY end end |