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.



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

#hostObject

Returns the value of attribute host.



696
697
698
# File 'lib/httpclient.rb', line 696

def host
  @host
end

#portObject

Returns the value of attribute port.



697
698
699
# File 'lib/httpclient.rb', line 697

def port
  @port
end

#schemeObject

: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

#addrObject



713
714
715
# File 'lib/httpclient.rb', line 713

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

#inspectObject



733
734
735
# File 'lib/httpclient.rb', line 733

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

#to_sObject



729
730
731
# File 'lib/httpclient.rb', line 729

def to_s
  addr
end