aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/people_list.rb
blob: 32e07089a617301228b1795fc18ab34f5670f962 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# encoding: UTF-8
require 'log4r'
require 'mauve/calendar_interface'

module Mauve 

  # Stores a list of name.
  #
  # @author Yann Golanski
  class PeopleList < Struct.new(:label, :list)

    # Default contrustor.
    def initialize (*args)
      super(*args)
    end

    def label
      self[:label]
    end

    alias username label

    def list
      self[:list] || []
    end

    #
    # Set up the logger
    def logger
      @logger ||=  Log4r::Logger.new self.class.to_s
    end

    #
    # Return the array of people
    #
    def people

      l = list.collect do |name|
        Configuration.current.people.has_key?(name) ? Configuration.current.people[name] : nil
      end.reject{|person| person.nil?}
      #
      # Hmm.. no-one in the list?!
      #
      logger.warn "No-one found in the people list for #{self.label}" if l.empty?

      l
    end

  end

end