Class: Lcms::Engine::Breadcrumbs

Inherits:
Object
  • Object
show all
Defined in:
app/entities/lcms/engine/breadcrumbs.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(resource) ⇒ Breadcrumbs

Returns a new instance of Breadcrumbs.



8
9
10
# File 'app/entities/lcms/engine/breadcrumbs.rb', line 8

def initialize(resource)
  @resource = resource
end

Instance Attribute Details

#resourceObject (readonly)

Returns the value of attribute resource.



6
7
8
# File 'app/entities/lcms/engine/breadcrumbs.rb', line 6

def resource
  @resource
end

Instance Method Details

#full_titleObject



12
13
14
15
16
17
# File 'app/entities/lcms/engine/breadcrumbs.rb', line 12

def full_title
  Lcms::Engine::Resource.hierarchy.map do |key|
    val = resource.[key.to_s]
    key == :subject ? val&.upcase : val&.humanize
  end.compact.join(' / ')
end

#piecesObject



19
20
21
22
23
24
25
26
27
28
# File 'app/entities/lcms/engine/breadcrumbs.rb', line 19

def pieces
  Lcms::Engine::Resource.hierarchy.map do |key|
    if resource.curriculum_type&.to_sym == key
      value = resource.[key.to_s]
      value.match?(/topic/i) ? value.upcase.sub('TOPIC', 'topic') : value
    else
      send(:"#{key}_abbrv")
    end
  end.compact
end

#short_piecesObject



30
31
32
# File 'app/entities/lcms/engine/breadcrumbs.rb', line 30

def short_pieces
  Lcms::Engine::Resource.hierarchy.map { |key| send(:"#{key}_abbrv", short: true) }.compact
end

#short_titleObject



34
35
36
# File 'app/entities/lcms/engine/breadcrumbs.rb', line 34

def short_title
  short_pieces.join(' / ')
end

#titleObject

ex: “ELA / G2 / M1 / U1 / lesson 8”



39
40
41
# File 'app/entities/lcms/engine/breadcrumbs.rb', line 39

def title
  pieces.join(' / ')
end