Sha256: c2ed9ad5ff3a7457575ef6ae1c4fb678b17fea00f7d77637ada800ce0bf41a8e
Contents?: true
Size: 970 Bytes
Versions: 2
Compression:
Stored size: 970 Bytes
Contents
module Mill class Navigator class Item attr_accessor :uri attr_accessor :title def initialize(uri:, title: nil) @uri = Addressable::URI.parse(uri) @title = title end end def initialize(items: []) @items = Hash[ items.map do |uri, title| item = Item.new(uri: uri, title: title) [item.uri, item] end ] end def items @items.values end def first_item @items.values.first end def last_item @items.values.last end def previous_item(uri) if (item = @items[uri]) i = @items.values.index(item) if i > 0 return @items.values[i - 1] end end nil end def next_item(uri) if (item = @items[uri]) i = @items.values.index(item) if i < @items.length - 1 return @items.values[i + 1] end end nil end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
mill-0.4 | lib/mill/navigator.rb |
mill-0.3 | lib/mill/navigator.rb |