Class: Trestle::Breadcrumb::Trail

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/trestle/breadcrumb.rb

Instance Method Summary collapse

Constructor Details

#initialize(breadcrumbs = []) ⇒ Trail

Returns a new instance of Trail.



31
32
33
# File 'lib/trestle/breadcrumb.rb', line 31

def initialize(breadcrumbs=[])
  @breadcrumbs = Array(breadcrumbs).compact
end

Instance Method Details

#==(other) ⇒ Object



35
36
37
# File 'lib/trestle/breadcrumb.rb', line 35

def ==(other)
  to_a == other.to_a
end

#append(label, path = nil) ⇒ Object



43
44
45
# File 'lib/trestle/breadcrumb.rb', line 43

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

#dupObject



39
40
41
# File 'lib/trestle/breadcrumb.rb', line 39

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

#prepend(label, path = nil) ⇒ Object



47
48
49
# File 'lib/trestle/breadcrumb.rb', line 47

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