Sha256: c3363a9c4cb0987eb556d9a755e327bc129b26b2e140765c0424d944802ce035

Contents?: true

Size: 666 Bytes

Versions: 3

Compression:

Stored size: 666 Bytes

Contents

module Trestle
  class Breadcrumb
    attr_reader :label, :path

    def initialize(label, path=nil)
      @label, @path = label, path
    end

    def ==(other)
      label == other.label && path == other.path
    end

    class Trail
      def initialize(breadcrumbs=[])
        @breadcrumbs = Array(breadcrumbs)
      end

      def dup
        self.class.new(@breadcrumbs.dup)
      end

      def append(label, path=nil)
        @breadcrumbs << Breadcrumb.new(label, path)
      end

      def prepend(label, path=nil)
        @breadcrumbs.unshift(Breadcrumb.new(label, path))
      end

      delegate :each, :first, :last, to: :@breadcrumbs
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
trestle-0.8.3 lib/trestle/breadcrumb.rb
trestle-0.8.2 lib/trestle/breadcrumb.rb
trestle-0.8.0 lib/trestle/breadcrumb.rb