Class: Navigatrix::Item
- Inherits:
-
Struct
- Object
- Struct
- Navigatrix::Item
- Extended by:
- Forwardable
- Defined in:
- lib/navigatrix/item.rb
Defined Under Namespace
Instance Attribute Summary collapse
-
#config ⇒ Object
writeonly
Sets the attribute config.
-
#context ⇒ Object
Returns the value of attribute context.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #active? ⇒ Boolean
- #children ⇒ Object
- #has_children? ⇒ Boolean
- #linked? ⇒ Boolean
- #path ⇒ Object
- #unlinked? ⇒ Boolean
Instance Attribute Details
#config=(value) ⇒ Object
Sets the attribute config
6 7 8 |
# File 'lib/navigatrix/item.rb', line 6 def config=(value) @config = value end |
#context ⇒ Object
Returns the value of attribute context
6 7 8 |
# File 'lib/navigatrix/item.rb', line 6 def context @context end |
#name ⇒ Object
Returns the value of attribute name
6 7 8 |
# File 'lib/navigatrix/item.rb', line 6 def name @name end |
Instance Method Details
#active? ⇒ Boolean
11 12 13 14 15 |
# File 'lib/navigatrix/item.rb', line 11 def active? applicable_active_state? || active_children? || unlinked? end |
#children ⇒ Object
29 30 31 |
# File 'lib/navigatrix/item.rb', line 29 def children @children ||= ItemCollection.new(config.children, context).items end |
#has_children? ⇒ Boolean
25 26 27 |
# File 'lib/navigatrix/item.rb', line 25 def has_children? children.any? end |
#linked? ⇒ Boolean
17 18 19 |
# File 'lib/navigatrix/item.rb', line 17 def linked? !unlinked? end |
#path ⇒ Object
33 34 35 |
# File 'lib/navigatrix/item.rb', line 33 def path @path ||= Path.new(config.path).call(context).to_s end |
#unlinked? ⇒ Boolean
21 22 23 |
# File 'lib/navigatrix/item.rb', line 21 def unlinked? unlinked_states_specified? ? unlinked_states.any?(&:applicable?) : currently_on_path? end |