Class: Termtter::Connection
- Inherits:
-
Object
- Object
- Termtter::Connection
- Defined in:
- lib/termtter.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.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/termtter.rb', line 83 def initialize @proxy_host = configatron.proxy.host @proxy_port = configatron.proxy.port @proxy_user = configatron.proxy.user_name @proxy_password = configatron.proxy.password @proxy_uri = nil @enable_ssl = configatron.enable_ssl @protocol = "http" @port = 80 unless @proxy_host.empty? @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.
81 82 83 |
# File 'lib/termtter.rb', line 81 def port @port end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
81 82 83 |
# File 'lib/termtter.rb', line 81 def protocol @protocol end |
#proxy_uri ⇒ Object (readonly)
Returns the value of attribute proxy_uri.
81 82 83 |
# File 'lib/termtter.rb', line 81 def proxy_uri @proxy_uri end |
Instance Method Details
#start(host, port, &block) ⇒ Object
107 108 109 110 111 112 |
# File 'lib/termtter.rb', line 107 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 |