aboutsummaryrefslogtreecommitdiff
path: root/lib/mauve/people_list.rb
blob: 23e0c1ee27265cdb5ec0cc55f63e81d666e63498 (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
# 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
      logger.warn "No-one found in the people list for #{self.label}" if self.list.empty?

      list.collect do |name|
        Configuration.current.people.has_key?(name) ? Configuration.current.people[name] : nil
      end.reject{|person| person.nil?}
    end

  end

end