Class: MercadoPublicoCl::Contact

Inherits:
Data
  • Object
show all
Defined in:
lib/mercado_publico_cl/value_objects/contact.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#emailObject (readonly)

Returns the value of attribute email

Returns:

  • (Object)

    the current value of email



4
5
6
# File 'lib/mercado_publico_cl/value_objects/contact.rb', line 4

def email
  @email
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



4
5
6
# File 'lib/mercado_publico_cl/value_objects/contact.rb', line 4

def name
  @name
end

#phoneObject (readonly)

Returns the value of attribute phone

Returns:

  • (Object)

    the current value of phone



4
5
6
# File 'lib/mercado_publico_cl/value_objects/contact.rb', line 4

def phone
  @phone
end

#roleObject (readonly)

Returns the value of attribute role

Returns:

  • (Object)

    the current value of role



4
5
6
# File 'lib/mercado_publico_cl/value_objects/contact.rb', line 4

def role
  @role
end

Class Method Details

.from_payload(raw) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/mercado_publico_cl/value_objects/contact.rb', line 5

def self.from_payload(raw)
  return nil if raw.nil?

  new(
    name: raw["NombreContacto"],
    role: raw["CargoContacto"],
    phone: raw["FonoContacto"],
    email: raw["MailContacto"]
  )
end

Instance Method Details

#empty?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/mercado_publico_cl/value_objects/contact.rb', line 16

def empty?
  [name, role, phone, email].all? { |v| v.nil? || v.to_s.empty? }
end

#inspectObject Also known as: to_s



20
21
22
# File 'lib/mercado_publico_cl/value_objects/contact.rb', line 20

def inspect
  "#<Contact name=#{name.inspect} role=#{role.inspect}>"
end