class Regional::Zone
Attributes
components[R]
Public Class Methods
new(zone)
click to toggle source
Make a zone of included ranges. A value of nil
means nowhere. +“*”+ means everywhere. Literally everywhere.
# File lib/regional/zone.rb, line 7 def initialize(zone) return unless zone return @components = ["0".."ZZZZZZ"] if zone == "*" @components = zone.split(/,\s*/).map do |str| array = str.split("-") if array.count == 1 array.first...array.first.succ elsif array.count == 2 array.first...array.last.succ else raise ArgumentError, "Range can only have one hyphen" end end end
Public Instance Methods
cover?(area)
click to toggle source
# File lib/regional/zone.rb, line 24 def cover?(area) @components.map{ |c| c.cover?(area.squeeze) }.inject do |m,o| m || o end end
inspect()
click to toggle source
# File lib/regional/zone.rb, line 30 def inspect "#<#{self.class.name} #{@components.join(", ")}>" end