Skip to content

Commit

Permalink
Add Path#len and make #pairs more flexible
Browse files Browse the repository at this point in the history
  • Loading branch information
Darrick Wiebe committed Oct 23, 2012
1 parent 5d8876a commit 234f55e
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/pacer/core/graph/path_route.rb
Expand Up @@ -59,9 +59,15 @@ def tails(et = :vertex)
end
end

def pairs
map element_type: :path, route_name: 'pairs' do |path|
[path.first, path.last]
def pairs(head = 0, tail = -1)
map element_type: :path, route_name: "pairs[#{ head },#{ tail }]" do |path|
[path[head], path[tail]]
end
end

def len(n)
select do |path|
n === path.length
end
end

Expand Down

0 comments on commit 234f55e

Please sign in to comment.