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.
784 785 786 787 788 789 790 791 792 793 794 795 796 |
# File 'lib/httpclient.rb', line 784 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.
781 782 783 |
# File 'lib/httpclient.rb', line 781 def host @host end |
#port ⇒ Object
Returns the value of attribute port.
782 783 784 |
# File 'lib/httpclient.rb', line 782 def port @port end |
#scheme ⇒ Object
:nodoc:
780 781 782 |
# File 'lib/httpclient.rb', line 780 def scheme @scheme end |
Instance Method Details
#==(rhs) ⇒ Object
806 807 808 809 810 811 812 |
# File 'lib/httpclient.rb', line 806 def ==(rhs) if rhs.is_a?(Site) ((@scheme == rhs.scheme) and (@host == rhs.host) and (@port == rhs.port)) else false end end |
#addr ⇒ Object
798 799 800 |
# File 'lib/httpclient.rb', line 798 def addr "#{@scheme}://#{@host}:#{@port.to_s}" end |
#inspect ⇒ Object
818 819 820 |
# File 'lib/httpclient.rb', line 818 def inspect sprintf("#<%s:0x%x %s>", self.class.name, __id__, @uri || addr) end |
#to_s ⇒ Object
814 815 816 |
# File 'lib/httpclient.rb', line 814 def to_s addr end |