Class: Justiz::Contact

Inherits:
Object
  • Object
show all
Defined in:
lib/justiz/contact.rb

Constant Summary collapse

FIELDS =
[:court, :location, :post, :phone, :fax, :justiz_id, :url, :email]

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Contact

Returns a new instance of Contact.



9
10
11
# File 'lib/justiz/contact.rb', line 9

def initialize(attributes = {})
  self.attributes = attributes
end

Instance Method Details

#attributes=(attributes) ⇒ Object



13
14
15
16
17
# File 'lib/justiz/contact.rb', line 13

def attributes=(attributes)
  attributes.each do |key, value|
    send("#{key}=", value) if respond_to?("#{key}=")
  end
end

#digestObject



34
35
36
37
38
39
40
# File 'lib/justiz/contact.rb', line 34

def digest
  sha256 = Digest::SHA2.new
  FIELDS.each do |field|
    sha256 << send(field)
  end
  Digest.hexencode(sha256.digest)
end

#idObject



19
20
21
22
23
24
# File 'lib/justiz/contact.rb', line 19

def id
  # too many duplicates
  #[court, justiz_id].compact.join("")
  # currently no duplicates
  [court, email].compact.join("")
end

#location_addressObject



26
27
28
# File 'lib/justiz/contact.rb', line 26

def location_address
  Address.new(location)
end

#post_addressObject



30
31
32
# File 'lib/justiz/contact.rb', line 30

def post_address
  Address.new(post)
end