Class: Avmtrf1::Oracle::Connection::StringBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/avmtrf1/oracle/connection/string_builder.rb

Constant Summary collapse

DEFAULT_PORT =
1521
FIELDS =
%w[user password host port service_name].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = nil) ⇒ StringBuilder

Returns a new instance of StringBuilder.



14
15
16
17
18
19
20
21
22
# File 'lib/avmtrf1/oracle/connection/string_builder.rb', line 14

def initialize(options = nil)
  if options.is_a?(String)
    self.string = options
  elsif options.is_a?(Hash)
    options.each do |k, v|
      send("#{k}=", v)
    end
  end
end

Instance Attribute Details

#stringObject

Returns the value of attribute string.



12
13
14
# File 'lib/avmtrf1/oracle/connection/string_builder.rb', line 12

def string
  @string
end

Instance Method Details

#buildObject



28
29
30
31
32
33
34
35
# File 'lib/avmtrf1/oracle/connection/string_builder.rb', line 28

def build
  if string
    string
  else
    validate_fields
    "#{user}/#{password}@//#{host}:#{port}/#{service_name}"
  end
end

#portObject



24
25
26
# File 'lib/avmtrf1/oracle/connection/string_builder.rb', line 24

def port
  @port || DEFAULT_PORT
end