Class: Pasqual::Database
- Inherits:
-
Object
- Object
- Pasqual::Database
- Defined in:
- lib/pasqual/database.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
- #command(statement) ⇒ Object
- #createdb(create_name = name) ⇒ Object
- #dropdb(drop_name = name) ⇒ Object
-
#initialize(url) ⇒ Database
constructor
A new instance of Database.
- #pipe_sql(file, dbname = name) ⇒ Object
Constructor Details
#initialize(url) ⇒ Database
Returns a new instance of Database.
11 12 13 14 15 16 17 18 |
# File 'lib/pasqual/database.rb', line 11 def initialize(url) uri = URI.parse url @username = uri.user @password = uri.password @host = uri.host @port = uri.port @name = uri.path.sub(/^\//, '') end |
Instance Attribute Details
#host ⇒ Object (readonly)
Returns the value of attribute host.
9 10 11 |
# File 'lib/pasqual/database.rb', line 9 def host @host end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/pasqual/database.rb', line 9 def name @name end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
9 10 11 |
# File 'lib/pasqual/database.rb', line 9 def password @password end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
9 10 11 |
# File 'lib/pasqual/database.rb', line 9 def port @port end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
9 10 11 |
# File 'lib/pasqual/database.rb', line 9 def username @username end |
Instance Method Details
#command(statement) ⇒ Object
32 33 34 |
# File 'lib/pasqual/database.rb', line 32 def command(statement) Psql.command statement, username, password, host, port, name end |
#createdb(create_name = name) ⇒ Object
24 25 26 |
# File 'lib/pasqual/database.rb', line 24 def createdb(create_name = name) Createdb.execute username, password, host, port, create_name end |