Class: Zm::Client::ConcatMember

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

Constant Summary collapse

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ConcatMember.



28
29
30
31
32
# File 'lib/zm/client/contact/contact_member.rb', line 28

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

Instance Attribute Details

#opObject (readonly)

Returns the value of attribute op.



26
27
28
# File 'lib/zm/client/contact/contact_member.rb', line 26

def op
  @op
end

#typeObject (readonly)

Returns the value of attribute type.



26
27
28
# File 'lib/zm/client/contact/contact_member.rb', line 26

def type
  @type
end

#valueObject (readonly)

Returns the value of attribute value.



26
27
28
# File 'lib/zm/client/contact/contact_member.rb', line 26

def value
  @value
end

Class Method Details

.find_type_by_value(value) ⇒ Object



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

def find_type_by_value(value)
  return INTERNAL if !value.to_i.zero? || Zm::Client::Regex::SHARED_CONTACT.match(value)
  return LDAP if Zm::Client::Regex::BASEDN_REGEX.match(value)

  FREE
end

.init_by_value(value) ⇒ Object



20
21
22
23
# File 'lib/zm/client/contact/contact_member.rb', line 20

def init_by_value(value)
  type_v = find_type_by_value(value)
  new(type_v, value)
end

Instance Method Details

#add!Object



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

def add!
  @op = ADD
end

#concatObject



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

def concat
  [@value, @type, @op]
end

#construct_soap_nodeObject



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

def construct_soap_node
  node = { type: @type, value: @value }
  node[:op] = @op unless @op.nil?
  node
end

#free?Boolean

Returns:

  • (Boolean)


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

def free?
  @type == FREE
end

#internal?Boolean

Returns:

  • (Boolean)


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

def internal?
  @type == INTERNAL && !Zm::Client::Regex::SHARED_CONTACT.match(value)
end

#ldap?Boolean

Returns:

  • (Boolean)


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

def ldap?
  @type == LDAP
end

#remove!Object



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

def remove!
  @op = DEL
end

#shared?Boolean

Returns:

  • (Boolean)


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

def shared?
  @type == INTERNAL && Zm::Client::Regex::SHARED_CONTACT.match(value)
end

#to_sObject



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

def to_s
  concat.join(' :: ')
end