Class: Zm::Client::ConcatMember

Inherits:
Object
  • Object
show all
Includes:
Inspector
Defined in:
lib/zm/client/contact/contact_member.rb

Constant Summary collapse

INTERNAL =
'C'
FREE =
'I'
LDAP =
'G'
ADD =
'+'
DEL =
'-'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Inspector

#inspect, #to_h, #to_s

Constructor Details

#initialize(type, value, op = nil) ⇒ ConcatMember

Returns a new instance of ConcatMember.



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/zm/client/contact/contact_member.rb', line 16

def initialize(type, value, op = nil)
  @shared_account_id = nil
  @op = op
  @type = type

  value_int = value.to_i

  if !value_int.zero?
    @value = value_int
  elsif Zm::Client::Regex::SHARED_CONTACT.match(value)
    part_value = value.split(':')
    @shared_account_id = part_value.first
    @value = part_value.last.to_i
  else
    @value = value
  end
end

Instance Attribute Details

#opObject (readonly)

Returns the value of attribute op.



14
15
16
# File 'lib/zm/client/contact/contact_member.rb', line 14

def op
  @op
end

#shared_account_idObject (readonly)

Returns the value of attribute shared_account_id.



14
15
16
# File 'lib/zm/client/contact/contact_member.rb', line 14

def 
  @shared_account_id
end

#typeObject (readonly)

Returns the value of attribute type.



14
15
16
# File 'lib/zm/client/contact/contact_member.rb', line 14

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



14
15
16
# File 'lib/zm/client/contact/contact_member.rb', line 14

def value
  @value
end

Instance Method Details

#add!Object



54
55
56
# File 'lib/zm/client/contact/contact_member.rb', line 54

def add!
  @op = ADD
end

#current?Boolean

Returns:

  • (Boolean)


50
51
52
# File 'lib/zm/client/contact/contact_member.rb', line 50

def current?
  @op.nil?
end

#email_addressObject



62
63
64
65
66
# File 'lib/zm/client/contact/contact_member.rb', line 62

def email_address
  return unless ldap?

  @email_address ||= @value.sub('uid=', '').sub(',ou=people,dc=', '@').gsub(',dc=', '.')
end

#free?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'lib/zm/client/contact/contact_member.rb', line 42

def free?
  @type == FREE
end

#instance_variables_mapObject



68
69
70
71
# File 'lib/zm/client/contact/contact_member.rb', line 68

def instance_variables_map
  email_address
  super
end

#internal?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/zm/client/contact/contact_member.rb', line 34

def internal?
  @type == INTERNAL && @value.is_a?(Integer)
end

#ldap?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/zm/client/contact/contact_member.rb', line 46

def ldap?
  @type == LDAP
end

#remove!Object



58
59
60
# File 'lib/zm/client/contact/contact_member.rb', line 58

def remove!
  @op = DEL
end

#shared?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/zm/client/contact/contact_member.rb', line 38

def shared?
  @type == INTERNAL && !@shared_account_id.nil?
end