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.
699 700 701 702 703 704 705 706 707 708 709 710 711 |
# File 'lib/httpclient.rb', line 699 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.
696 697 698 |
# File 'lib/httpclient.rb', line 696 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
697 698 699 |
# File 'lib/httpclient.rb', line 697 def port @port end |
#scheme ⇒ Object
:nodoc:
695 696 697 |
# File 'lib/httpclient.rb', line 695 def scheme @scheme end |
Instance Method Details
#==(rhs) ⇒ Object
721 722 723 724 725 726 727 |
# File 'lib/httpclient.rb', line 721 def ==(rhs) if rhs.is_a?(Site) ((@scheme == rhs.scheme) and (@host == rhs.host) and (@port == rhs.port)) else false end end |
#addr ⇒ Object
713 714 715 |
# File 'lib/httpclient.rb', line 713 def addr "#{@scheme}://#{@host}:#{@port.to_s}" end |
#inspect ⇒ Object
733 734 735 |
# File 'lib/httpclient.rb', line 733 def inspect sprintf("#<%s:0x%x %s>", self.class.name, __id__, @uri || addr) end |
#to_s ⇒ Object
729 730 731 |
# File 'lib/httpclient.rb', line 729 def to_s addr end |