Class: Lcms::Engine::Breadcrumbs
- Inherits:
-
Object
- Object
- Lcms::Engine::Breadcrumbs
- Defined in:
- app/entities/lcms/engine/breadcrumbs.rb
Instance Attribute Summary collapse
-
#resource ⇒ Object
readonly
Returns the value of attribute resource.
Instance Method Summary collapse
- #full_title ⇒ Object
-
#initialize(resource) ⇒ Breadcrumbs
constructor
A new instance of Breadcrumbs.
- #pieces ⇒ Object
- #short_pieces ⇒ Object
- #short_title ⇒ Object
-
#title ⇒ Object
ex: “ELA / G2 / M1 / U1 / lesson 8”.
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
#resource ⇒ Object (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_title ⇒ Object
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 |
#pieces ⇒ Object
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_pieces ⇒ Object
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_title ⇒ Object
34 35 36 |
# File 'app/entities/lcms/engine/breadcrumbs.rb', line 34 def short_title short_pieces.join(' / ') end |
#title ⇒ Object
ex: “ELA / G2 / M1 / U1 / lesson 8”
39 40 41 |
# File 'app/entities/lcms/engine/breadcrumbs.rb', line 39 def title pieces.join(' / ') end |