Class: Vedeu::Groups::Group
- Inherits:
-
Object
- Object
- Vedeu::Groups::Group
- Includes:
- Repositories::Model, Toggleable
- Defined in:
- lib/vedeu/groups/group.rb,
lib/vedeu/groups/repository.rb
Overview
Groups
Instance Attribute Summary collapse
Attributes included from Toggleable
Attributes included from Repositories::Model
Instance Method Summary collapse
-
#add(member) ⇒ Vedeu::Groups::Group
private
Add a member to the group by name.
-
#attributes ⇒ Hash<Symbol => void>
private
Returns the attributes of the group.
-
#by_zindex ⇒ Array<String>
private
Return the members of the group sorted by the zindex of the members.
-
#defaults ⇒ Hash<Symbol => void>
private
private
The default options/attributes for a new instance of this class.
-
#deputy(client = nil) ⇒ Vedeu::Groups::DSL
private
Returns a DSL instance responsible for defining the DSL methods of this model.
-
#eql?(other) ⇒ Boolean
(also: #==)
private
An object is equal when its values are the same.
-
#hide ⇒ Vedeu::Groups::Group
private
Hide the named group of interfaces, or without a name, the group of the currently focussed interface.
-
#initialize(attributes = {}) ⇒ Vedeu::Groups::Group
constructor
private
Return a new instance of Vedeu::Groups::Group.
-
#interfaces ⇒ Array<Vedeu::Interfaces::Interface]
private
private
Return the interfaces for all members of the group.
-
#members ⇒ Set
private
Return the members of the group.
-
#remove(member) ⇒ Vedeu::Groups::Group
private
Remove a member from the group by name.
-
#reset! ⇒ Vedeu::Groups::Group
(also: #reset)
private
Remove all members from the group.
-
#show ⇒ Vedeu::Groups::Group
private
Show the named group of interfaces, or without a name, the group of the currently focussed interface.
Methods included from Toggleable
Methods included from Repositories::Model
Constructor Details
#initialize(attributes = {}) ⇒ Vedeu::Groups::Group
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.
A group being visible or not may not necessarily mean the members are of the same state.
Return a new instance of Vedeu::Groups::Group.
38 39 40 41 42 |
# File 'lib/vedeu/groups/group.rb', line 38 def initialize(attributes = {}) defaults.merge!(attributes).each do |key, value| instance_variable_set("@#{key}", value) end end |
Instance Attribute Details
#name ⇒ String
19 20 21 |
# File 'lib/vedeu/groups/group.rb', line 19 def name @name end |
Instance Method Details
#add(member) ⇒ Vedeu::Groups::Group
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 a member to the group by name.
48 49 50 51 52 |
# File 'lib/vedeu/groups/group.rb', line 48 def add(member) attrs = attributes.merge!(members: members.add(member)) Vedeu::Groups::Group.store(attrs) end |
#attributes ⇒ Hash<Symbol => void>
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 the attributes of the group.
57 58 59 60 61 62 63 64 |
# File 'lib/vedeu/groups/group.rb', line 57 def attributes { name: name, members: members, repository: repository, visible: visible, } end |
#by_zindex ⇒ Array<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.
Return the members of the group sorted by the zindex of the members.
70 71 72 |
# File 'lib/vedeu/groups/group.rb', line 70 def by_zindex interfaces.sort_by(&:zindex).map(&:name) end |
#defaults ⇒ Hash<Symbol => void> (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.
The default options/attributes for a new instance of this class.
164 165 166 167 168 169 170 171 |
# File 'lib/vedeu/groups/group.rb', line 164 def defaults { members: Set.new, name: nil, repository: Vedeu.groups, visible: true, } end |
#deputy(client = nil) ⇒ Vedeu::Groups::DSL
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 DSL instance responsible for defining the DSL methods of this model.
82 83 84 |
# File 'lib/vedeu/groups/group.rb', line 82 def deputy(client = nil) Vedeu::Groups::DSL.new(self, client) end |
#eql?(other) ⇒ Boolean Also known as: ==
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.
An object is equal when its values are the same.
90 91 92 93 |
# File 'lib/vedeu/groups/group.rb', line 90 def eql?(other) self.class.equal?(other.class) && name == other.name && members == other.members end |
#hide ⇒ Vedeu::Groups::Group
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.
The action of showing a group will effectively clear the terminal and show the new group, therefore hiding the group may not be necessary.
Hide the named group of interfaces, or without a name, the group of the currently focussed interface. Useful for hiding part of that which is currently displaying in the terminal.
110 111 112 113 114 115 116 |
# File 'lib/vedeu/groups/group.rb', line 110 def hide super @members.each { |member| Vedeu.trigger(:_hide_interface_, member) } self end |
#interfaces ⇒ Array<Vedeu::Interfaces::Interface] (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.
Return the interfaces for all members of the group.
176 177 178 |
# File 'lib/vedeu/groups/group.rb', line 176 def interfaces members.map { |name| Vedeu.interfaces.by_name(name) } end |
#members ⇒ Set
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 members of the group.
121 122 123 |
# File 'lib/vedeu/groups/group.rb', line 121 def members @_members ||= Set.new(@members) end |
#remove(member) ⇒ Vedeu::Groups::Group
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.
Remove a member from the group by name.
129 130 131 132 133 |
# File 'lib/vedeu/groups/group.rb', line 129 def remove(member) attrs = attributes.merge!(members: members.delete(member)) Vedeu::Groups::Group.store(attrs) end |
#reset! ⇒ Vedeu::Groups::Group Also known as: reset
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.
Remove all members from the group.
138 139 140 141 142 |
# File 'lib/vedeu/groups/group.rb', line 138 def reset! attrs = defaults.merge!(name: name) Vedeu::Groups::Group.store(attrs) end |
#show ⇒ Vedeu::Groups::Group
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.
Show the named group of interfaces, or without a name, the group of the currently focussed interface.
153 154 155 156 157 158 159 |
# File 'lib/vedeu/groups/group.rb', line 153 def show super @members.each { |member| Vedeu.trigger(:_show_interface_, member) } self end |