Class: Termtter::Connection
- Inherits:
-
Object
- Object
- Termtter::Connection
- Defined in:
- lib/termtter/connection.rb
Instance Attribute Summary collapse
-
#port ⇒ Object
readonly
Returns the value of attribute port.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#proxy_uri ⇒ Object
readonly
Returns the value of attribute proxy_uri.
Instance Method Summary collapse
-
#initialize ⇒ Connection
constructor
A new instance of Connection.
- #start(host, port, &block) ⇒ Object
Constructor Details
#initialize ⇒ Connection
Returns a new instance of Connection.
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 |
# File 'lib/termtter/connection.rb', line 7 def initialize unless config.proxy.empty? @proxy_host = config.proxy.host @proxy_port = config.proxy.port @proxy_user = config.proxy.user_name @proxy_password = config.proxy.password @proxy_uri = nil @enable_ssl = config.enable_ssl end @protocol = "http" @port = 80 if @proxy_host @http_class = Net::HTTP::Proxy(@proxy_host, @proxy_port, @proxy_user, @proxy_password) @proxy_uri = "http://" + @proxy_host + ":" + @proxy_port + "/" else @http_class = Net::HTTP end if @enable_ssl @protocol = "https" @port = 443 end end |
Instance Attribute Details
#port ⇒ Object (readonly)
Returns the value of attribute port.
5 6 7 |
# File 'lib/termtter/connection.rb', line 5 def port @port end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
5 6 7 |
# File 'lib/termtter/connection.rb', line 5 def protocol @protocol end |
#proxy_uri ⇒ Object (readonly)
Returns the value of attribute proxy_uri.
5 6 7 |
# File 'lib/termtter/connection.rb', line 5 def proxy_uri @proxy_uri end |
Instance Method Details
#start(host, port, &block) ⇒ Object
33 34 35 36 37 38 |
# File 'lib/termtter/connection.rb', line 33 def start(host, port, &block) http = @http_class.new(host, port) http.use_ssl = @enable_ssl http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl? http.start(&block) end |