Class: Trestle::Breadcrumb

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

Defined Under Namespace

Classes: Trail

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label, path = nil) ⇒ Breadcrumb

Returns a new instance of Breadcrumb.


5
6
7
# File 'lib/trestle/breadcrumb.rb', line 5

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

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label


3
4
5
# File 'lib/trestle/breadcrumb.rb', line 3

def label
  @label
end

#pathObject (readonly)

Returns the value of attribute path


3
4
5
# File 'lib/trestle/breadcrumb.rb', line 3

def path
  @path
end

Class Method Details

.cast(obj) ⇒ Object


13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/trestle/breadcrumb.rb', line 13

def self.cast(obj)
  case obj
  when Breadcrumb
    obj
  when String
    new(obj)
  when Array
    new(*obj)
  when NilClass, false
    nil
  else
    raise ArgumentError, "Unable to cast #{obj.inspect} to Breadcrumb"
  end
end

Instance Method Details

#==(other) ⇒ Object


9
10
11
# File 'lib/trestle/breadcrumb.rb', line 9

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