Module: Vedeu::Focus Private

Extended by:
Focus
Includes:
Common, Repository
Included in:
Focus
Defined in:
lib/vedeu/repositories/focus.rb

Overview

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

The Focus repository is simply a collection of interface names, this module serving to store and manipulate the which interface is currently being focussed.

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Repository

#all, #find, #missing_required, #reset, #storage, #validate_attributes!

Methods included from Common

#defined_value?

Class Method Details

.add(attributes) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Add an interface name to the focus list unless it is already registered.

Parameters:

  • attributes (String)

Returns:

  • (Array)


36
37
38
39
40
41
42
43
44
45
46
# File 'lib/vedeu/repositories/focus.rb', line 36

def add(attributes)
  validate_attributes!(attributes)

  if registered?(attributes[:name])
    storage

  else
    storage << attributes[:name]

  end
end

.by_name(name) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Focus an interface by name.

Parameters:

  • name (String)

Returns:

  • (String)

Raises:



53
54
55
56
57
58
59
60
61
# File 'lib/vedeu/repositories/focus.rb', line 53

def by_name(name)
  fail InterfaceNotFound unless storage.include?(name)

  storage.rotate!(storage.index(name))

  Vedeu.log("Interface in focus: '#{current}'")

  current
end

.currentString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return the interface currently focussed.

Returns:

  • (String)

Raises:



68
69
70
71
72
# File 'lib/vedeu/repositories/focus.rb', line 68

def current
  fail NoInterfacesDefined if storage.empty?

  storage.first
end

.current?(name) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether the named interface is focussed.

Parameters:

  • name (String)

Returns:

  • (Boolean)


78
79
80
# File 'lib/vedeu/repositories/focus.rb', line 78

def current?(name)
  current == name
end

.in_memoryArray (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns an empty collection ready for the storing of interface names.

Returns:

  • (Array)


127
128
129
# File 'lib/vedeu/repositories/focus.rb', line 127

def in_memory
  []
end

.next_itemString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Put the next interface relative to the current interfaces in focus.

Returns:

  • (String)


85
86
87
88
89
90
91
# File 'lib/vedeu/repositories/focus.rb', line 85

def next_item
  storage.rotate!

  Vedeu.log("Interface in focus: '#{current}'")

  current
end

.prev_itemString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Put the previous interface relative to the current interface in focus.

Returns:

  • (String)


96
97
98
99
100
101
102
# File 'lib/vedeu/repositories/focus.rb', line 96

def prev_item
  storage.rotate!(-1)

  Vedeu.log("Interface in focus: '#{current}'")

  current
end

.registeredArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns all registered interfaces by name.

Returns:

  • (Array)


107
108
109
# File 'lib/vedeu/repositories/focus.rb', line 107

def registered
  storage
end

.registered?(name) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether the named interface is registered.

Returns:

  • (Boolean)


115
116
117
118
119
# File 'lib/vedeu/repositories/focus.rb', line 115

def registered?(name)
  return false if storage.empty?

  storage.include?(name)
end

Instance Method Details

#add(attributes) ⇒ Array

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Add an interface name to the focus list unless it is already registered.

Parameters:

  • attributes (String)

Returns:

  • (Array)


36
37
38
39
40
41
42
43
44
45
46
# File 'lib/vedeu/repositories/focus.rb', line 36

def add(attributes)
  validate_attributes!(attributes)

  if registered?(attributes[:name])
    storage

  else
    storage << attributes[:name]

  end
end

#by_name(name) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Focus an interface by name.

Parameters:

  • name (String)

Returns:

  • (String)

Raises:



53
54
55
56
57
58
59
60
61
# File 'lib/vedeu/repositories/focus.rb', line 53

def by_name(name)
  fail InterfaceNotFound unless storage.include?(name)

  storage.rotate!(storage.index(name))

  Vedeu.log("Interface in focus: '#{current}'")

  current
end

#currentString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Return the interface currently focussed.

Returns:

  • (String)

Raises:



68
69
70
71
72
# File 'lib/vedeu/repositories/focus.rb', line 68

def current
  fail NoInterfacesDefined if storage.empty?

  storage.first
end

#current?(name) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether the named interface is focussed.

Parameters:

  • name (String)

Returns:

  • (Boolean)


78
79
80
# File 'lib/vedeu/repositories/focus.rb', line 78

def current?(name)
  current == name
end

#in_memoryArray (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns an empty collection ready for the storing of interface names.

Returns:

  • (Array)


127
128
129
# File 'lib/vedeu/repositories/focus.rb', line 127

def in_memory
  []
end

#next_itemString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Put the next interface relative to the current interfaces in focus.

Returns:

  • (String)


85
86
87
88
89
90
91
# File 'lib/vedeu/repositories/focus.rb', line 85

def next_item
  storage.rotate!

  Vedeu.log("Interface in focus: '#{current}'")

  current
end

#prev_itemString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Put the previous interface relative to the current interface in focus.

Returns:

  • (String)


96
97
98
99
100
101
102
# File 'lib/vedeu/repositories/focus.rb', line 96

def prev_item
  storage.rotate!(-1)

  Vedeu.log("Interface in focus: '#{current}'")

  current
end

#registeredArray

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns all registered interfaces by name.

Returns:

  • (Array)


107
108
109
# File 'lib/vedeu/repositories/focus.rb', line 107

def registered
  storage
end

#registered?(name) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a boolean indicating whether the named interface is registered.

Returns:

  • (Boolean)


115
116
117
118
119
# File 'lib/vedeu/repositories/focus.rb', line 115

def registered?(name)
  return false if storage.empty?

  storage.include?(name)
end