1 class OldSegment < ActiveRecord::Base
2 set_table_name 'segments'
4 validates_presence_of :user_id, :timestamp
5 validates_inclusion_of :visible, :in => [ true, false ]
6 validates_numericality_of :node_a, :node_b
10 def self.from_segment(segment)
11 old_segment = OldSegment.new
12 old_segment.node_a = segment.node_a
13 old_segment.node_b = segment.node_b
14 old_segment.visible = segment.visible
15 old_segment.tags = segment.tags
16 old_segment.timestamp = segment.timestamp
17 old_segment.user_id = segment.user_id
18 old_segment.id = segment.id
23 el1 = XML::Node.new 'segment'
24 el1['id'] = self.id.to_s
25 el1['from'] = self.node_a.to_s
26 el1['to'] = self.node_b.to_s
27 el1['user'] = self.user.display_name if self.user.data_public?
28 Segment.split_tags(el1, self.tags)
29 el1['visible'] = self.visible.to_s
30 el1['timestamp'] = self.timestamp.xmlschema