aboutsummaryrefslogtreecommitdiffstats
path: root/app/models/chouette/objectid/stif_reflex.rb
blob: 770f3c433844527d65fd706880b8fa4cc4cec59e (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
module Chouette
  module Objectid
    class StifReflex < Chouette::Objectid::Netex

      attr_accessor :country_code, :zip_code
      validates_presence_of :country_code, :zip_code
      validates :creation_id, presence: false

      @@format = /^([A-Za-z_]+):([0-9A-Za-z_-]+):([A-Za-z]+):([0-9A-Za-z_-]+):([A-Za-z]+)$/

      def initialize(**attributes)
        @provider_id = attributes[:provider_id]
        @country_code = attributes[:country_code]
        @zip_code = attributes[:zip_code]
        super
      end

      def to_s
        "#{self.country_code}:#{self.zip_code}:#{self.object_type}:#{self.local_id}:#{self.provider_id}"
      end

      def short_id
        local_id
      end
    end
  end
end