Class: Gaah::Calendar::Who

Inherits:
Object
  • Object
show all
Defined in:
lib/gaah/calendar/who.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Who

Returns a new instance of Who.



5
6
7
8
# File 'lib/gaah/calendar/who.rb', line 5

def initialize(json)
  @name  = json['displayName'].to_s
  @email = json['email'].to_s
end

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email.



4
5
6
# File 'lib/gaah/calendar/who.rb', line 4

def email
  @email
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/gaah/calendar/who.rb', line 4

def name
  @name
end

Class Method Details

.batch_process(xml, exclude_catch_all_user = true) ⇒ Object



21
22
23
24
25
26
27
28
29
30
# File 'lib/gaah/calendar/who.rb', line 21

def self.batch_process(xml, exclude_catch_all_user = true)
  (xml/:entry).map do |entry|
    who = new(entry)
    if exclude_catch_all_user && who.catch_all_user?
      nil
    else
      who
    end
  end.compact
end

Instance Method Details

#catch_all_user?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/gaah/calendar/who.rb', line 10

def catch_all_user?
  self.email.to_s =~ /^\.@/
end

#to_json(*args) ⇒ Object



14
15
16
17
18
19
# File 'lib/gaah/calendar/who.rb', line 14

def to_json(*args)
  {
    name:  name,
    email: email,
  }.to_json
end