-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsolar_system.rb
More file actions
33 lines (29 loc) · 815 Bytes
/
Copy pathsolar_system.rb
File metadata and controls
33 lines (29 loc) · 815 Bytes
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
class SolarSystem < ActiveRecord::Base
set_table_name "mapSolarSystems"
set_primary_key "solarSystemID"
## shorthand methods
#
def name
self.solarSystemName
end
def region
Region.find( self.regionID )
end
## activerecord methods
def self.find_by_name( name )
SolarSystem.find(:first, :conditions => ['solarSystemName = ?', name])
end
## Formatting methods
#
def to_xml( options = {} )
options[:indent] ||= 2
xml = options[:builder] ||= Builder::XmlMarkup.new(:indent => options[:ident])
xml.instruct! unless options[:skip_instruct]
xml.system do
xml.tag!(:id, self.id)
xml.tag!(:name, self.name)
xml.tag!(:security, sprintf('%.2f',self.security))
self.region.to_xml(:skip_instruct => true, :builder => xml)
end
end
end