blob: 7953c6b1205d209a65c797b26cea67be882c85e0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
module Chouette
module Objectid
class Netex
include ActiveModel::Model
attr_accessor :provider_id, :object_type, :local_id, :creation_id
validates_presence_of :provider_id, :object_type, :local_id, :creation_id
validate :must_respect_format
def initialize(**attributes)
@provider_id ||= (attributes[:provider_id] ||= 'chouette')
@object_type = attributes[:object_type]
@local_id = attributes[:local_id]
@creation_id = (attributes[:creation_id] ||= 'LOC')
end
@@format = /^([A-Za-z_-]+):([A-Za-z]+):([0-9A-Za-z_-]+):([A-Za-z]+)$/
cattr_reader :format
def to_s
"#{self.provider_id}:#{self.object_type}:#{self.local_id}:#{self.creation_id}"
end
def must_respect_format
self.to_s.match(format)
end
def short_id
local_id
end
end
end
end
|