Class: Rsconn::JdbcUrl
- Inherits:
-
Object
- Object
- Rsconn::JdbcUrl
- Defined in:
- lib/rsconn/jdbc_url.rb
Instance Attribute Summary collapse
-
#database ⇒ Object
readonly
Returns the value of attribute database.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#initialize(url) ⇒ JdbcUrl
constructor
A new instance of JdbcUrl.
Constructor Details
#initialize(url) ⇒ JdbcUrl
Returns a new instance of JdbcUrl.
5 6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/rsconn/jdbc_url.rb', line 5 def initialize(url) @url = url @host = @url.split('//').last.split(':').first @port = @url.split(':').last.split('/').first.to_i @database = @url.split('/').last.split('?').first db_type = @url.split(':')[1] if db_type != 'postgresql' fail ArgumentError, 'Only works with a "postgresql" JDBC URL' end end |
Instance Attribute Details
#database ⇒ Object (readonly)
Returns the value of attribute database.
3 4 5 |
# File 'lib/rsconn/jdbc_url.rb', line 3 def database @database end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
3 4 5 |
# File 'lib/rsconn/jdbc_url.rb', line 3 def host @host end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
3 4 5 |
# File 'lib/rsconn/jdbc_url.rb', line 3 def port @port end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
3 4 5 |
# File 'lib/rsconn/jdbc_url.rb', line 3 def url @url end |