Class: Chouette::ObjectId

Inherits:
String
  • Object
show all
Defined in:
app/models/chouette/object_id.rb

Constant Summary collapse

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.create(system_id, object_type, local_id) ⇒ Object



27
28
29
# File 'app/models/chouette/object_id.rb', line 27

def self.create(system_id, object_type, local_id)
  new [system_id, object_type, local_id].join(":")
end

.new(string) ⇒ Object



31
32
33
34
# File 'app/models/chouette/object_id.rb', line 31

def self.new(string)
  string ||= ""
  self === string ? string : super
end

Instance Method Details

#local_idObject



23
24
25
# File 'app/models/chouette/object_id.rb', line 23

def local_id
  parts.try(:third)
end

#object_typeObject



19
20
21
# File 'app/models/chouette/object_id.rb', line 19

def object_type
  parts.try(:second)
end

#partsObject



11
12
13
# File 'app/models/chouette/object_id.rb', line 11

def parts
  match(format).try(:captures)
end

#system_idObject



15
16
17
# File 'app/models/chouette/object_id.rb', line 15

def system_id
  parts.try(:first)
end

#valid?Boolean Also known as: objectid?

Returns:

  • (Boolean)


3
4
5
# File 'app/models/chouette/object_id.rb', line 3

def valid?
  parts.present?
end