Class: Keyman::Group

Inherits:
Object
  • Object
show all
Defined in:
lib/keyman/group.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeGroup

Returns a new instance of Group.



6
7
8
# File 'lib/keyman/group.rb', line 6

def initialize
  @users = []
end

Instance Attribute Details

#nameObject

Returns the value of attribute name.



4
5
6
# File 'lib/keyman/group.rb', line 4

def name
  @name
end

#usersObject

Returns the value of attribute users.



4
5
6
# File 'lib/keyman/group.rb', line 4

def users
  @users
end

Class Method Details

.add(name, &block) ⇒ Object

Add a new group with the given name



11
12
13
14
15
16
17
18
19
# File 'lib/keyman/group.rb', line 11

def self.add(name, &block)
  if existing = Keyman.user_or_group_for(name)
    raise Error, "#{existing.class.to_s.split('::').last} already exists for '#{name}' - cannot define user with this name."
  end
  g = Group.new
  g.name = name
  g.instance_eval(&block)
  Keyman.groups << g
end

Instance Method Details

#user(*args) ⇒ Object

Add a new user to the group



22
23
24
# File 'lib/keyman/group.rb', line 22

def user(*args)
  @users << User.add(*args)
end