Class: Osmer::Target::Pg
- Inherits:
-
Object
- Object
- Osmer::Target::Pg
- Defined in:
- lib/osmer/target/pg.rb
Defined Under Namespace
Classes: Connection
Constant Summary collapse
- GEOTYPES =
{ 'point' => 'POINT', 'line' => 'LINESTRING', 'polygon' => 'POLYGON', 'multiline' => 'MULTILINESTRING', 'multipolygon' => 'MULTIPOLYGON' }
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #[](key) ⇒ Object
- #geometry_type(type) ⇒ Object
- #in_transaction ⇒ Object
-
#initialize(options) ⇒ Pg
constructor
A new instance of Pg.
Constructor Details
#initialize(options) ⇒ Pg
Returns a new instance of Pg.
9 10 11 |
# File 'lib/osmer/target/pg.rb', line 9 def initialize() @options = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
7 8 9 |
# File 'lib/osmer/target/pg.rb', line 7 def @options end |
Instance Method Details
#[](key) ⇒ Object
13 14 15 |
# File 'lib/osmer/target/pg.rb', line 13 def [](key) @options[key] end |
#geometry_type(type) ⇒ Object
33 34 35 |
# File 'lib/osmer/target/pg.rb', line 33 def geometry_type(type) GEOTYPES[type.to_s.gsub(/s\z/,'')] or raise StandardError.new("Unknown geometry type #{type.inspect}") end |
#in_transaction ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/osmer/target/pg.rb', line 17 def in_transaction conn = Connection.new begin conn.exec "BEGIN TRANSACTION" yield conn conn.exec "COMMIT" ensure conn.close end end |