Class: HTTPClient::Site
- Inherits:
-
Object
- Object
- HTTPClient::Site
- Defined in:
- lib/httpclient.rb
Overview
HTTPClient::Site – manage a site(host and port)
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#port ⇒ Object
Returns the value of attribute port.
-
#scheme ⇒ Object
:nodoc:.
Instance Method Summary collapse
- #==(rhs) ⇒ Object
- #addr ⇒ Object
-
#initialize(uri = nil) ⇒ Site
constructor
A new instance of Site.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(uri = nil) ⇒ Site
Returns a new instance of Site.
700 701 702 703 704 705 706 707 708 709 710 711 712 |
# File 'lib/httpclient.rb', line 700 def initialize(uri = nil) if uri @uri = uri @scheme = uri.scheme @host = uri.host @port = uri.port.to_i else @uri = nil @scheme = 'tcp' @host = '0.0.0.0' @port = 0 end end |
Instance Attribute Details
#host ⇒ Object
Returns the value of attribute host.
697 698 699 |
# File 'lib/httpclient.rb', line 697 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
698 699 700 |
# File 'lib/httpclient.rb', line 698 def port @port end |
#scheme ⇒ Object
:nodoc:
696 697 698 |
# File 'lib/httpclient.rb', line 696 def scheme @scheme end |
Instance Method Details
#==(rhs) ⇒ Object
722 723 724 725 726 727 728 |
# File 'lib/httpclient.rb', line 722 def ==(rhs) if rhs.is_a?(Site) ((@scheme == rhs.scheme) and (@host == rhs.host) and (@port == rhs.port)) else false end end |
#addr ⇒ Object
714 715 716 |
# File 'lib/httpclient.rb', line 714 def addr "#{@scheme}://#{@host}:#{@port.to_s}" end |
#inspect ⇒ Object
734 735 736 |
# File 'lib/httpclient.rb', line 734 def inspect sprintf("#<%s:0x%x %s>", self.class.name, __id__, @uri || addr) end |
#to_s ⇒ Object
730 731 732 |
# File 'lib/httpclient.rb', line 730 def to_s addr end |