Class: Navigatrix::Item

Inherits:
Struct
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/navigatrix/item.rb

Defined Under Namespace

Classes: Path, State

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#config=(value) ⇒ Object

Sets the attribute config

Parameters:

  • value (Object)

    the value to set the attribute config to.

Returns:

  • (Object)

    the newly set value



6
7
8
# File 'lib/navigatrix/item.rb', line 6

def config=(value)
  @config = value
end

#contextObject

Returns the value of attribute context

Returns:

  • (Object)

    the current value of context



6
7
8
# File 'lib/navigatrix/item.rb', line 6

def context
  @context
end

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



6
7
8
# File 'lib/navigatrix/item.rb', line 6

def name
  @name
end

Instance Method Details

#active?Boolean

Returns:

  • (Boolean)


11
12
13
14
15
# File 'lib/navigatrix/item.rb', line 11

def active?
  applicable_active_state? ||
  active_children? ||
  unlinked?
end

#childrenObject



29
30
31
# File 'lib/navigatrix/item.rb', line 29

def children
  @children ||= ItemCollection.new(config.children, context).items
end

#has_children?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/navigatrix/item.rb', line 25

def has_children?
  children.any?
end

#linked?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/navigatrix/item.rb', line 17

def linked?
  !unlinked?
end

#pathObject



33
34
35
# File 'lib/navigatrix/item.rb', line 33

def path
  @path ||= Path.new(config.path).call(context).to_s
end

#unlinked?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/navigatrix/item.rb', line 21

def unlinked?
  unlinked_states_specified? ? unlinked_states.any?(&:applicable?) : currently_on_path?
end