Harbor::Layouts
Public Class Methods
Public Instance Methods
clear()
# File lib/harbor/layouts.rb, line 41 41: def clear 42: @default = nil 43: @map.clear 44: end
default(layout)
# File lib/harbor/layouts.rb, line 27 27: def default(layout) 28: @default = layout 29: end
each()
# File lib/harbor/layouts.rb, line 31 31: def each 32: @map.each { |item| yield item } 33: end
map(fragment, layout)
# File lib/harbor/layouts.rb, line 11 11: def map(fragment, layout) 12: fragment = fragment.squeeze("*").squeeze("/").sub(%r{/$}, "").gsub("*", ".*") 13: specificity = fragment_specificity(fragment) 14: 15: regexp = Regexp.new("^#{fragment}") 16: 17: if previous = @map.assoc(regexp) 18: @map[@map.index(previous)] = [regexp, layout, specificity] 19: else 20: @map << [regexp, layout, specificity] 21: end 22: 23: sort! 24: @map 25: end