Class: HTTPClient::Site

Inherits:
Object
  • Object
show all
Defined in:
lib/httpclient.rb

Overview

HTTPClient::Site – manage a site(host and port)

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#hostObject

Returns the value of attribute host.



781
782
783
# File 'lib/httpclient.rb', line 781

def host
  @host
end

#portObject

Returns the value of attribute port.



782
783
784
# File 'lib/httpclient.rb', line 782

def port
  @port
end

#schemeObject

: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

#addrObject



798
799
800
# File 'lib/httpclient.rb', line 798

def addr
  "#{@scheme}://#{@host}:#{@port.to_s}"
end

#inspectObject



818
819
820
# File 'lib/httpclient.rb', line 818

def inspect
  sprintf("#<%s:0x%x %s>", self.class.name, __id__, @uri || addr)
end

#to_sObject



814
815
816
# File 'lib/httpclient.rb', line 814

def to_s
  addr
end