Class: HTTPAccess2::Site

Inherits:
Object
  • Object
show all
Defined in:
lib/http-access2.rb

Overview

HTTPAccess2::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.



749
750
751
752
753
754
755
756
757
758
759
# File 'lib/http-access2.rb', line 749

def initialize(uri = nil)
  if uri
    @scheme = uri.scheme
    @host = uri.host
    @port = uri.port.to_i
  else
    @scheme = 'tcp'
    @host = '0.0.0.0'
    @port = 0
  end
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



746
747
748
# File 'lib/http-access2.rb', line 746

def host
  @host
end

#portObject

Returns the value of attribute port.



747
748
749
# File 'lib/http-access2.rb', line 747

def port
  @port
end

#schemeObject

:nodoc:



745
746
747
# File 'lib/http-access2.rb', line 745

def scheme
  @scheme
end

Instance Method Details

#==(rhs) ⇒ Object



769
770
771
772
773
774
775
# File 'lib/http-access2.rb', line 769

def ==(rhs)
  if rhs.is_a?(Site)
    ((@scheme == rhs.scheme) and (@host == rhs.host) and (@port == rhs.port))
  else
    false
  end
end

#addrObject



761
762
763
# File 'lib/http-access2.rb', line 761

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

#inspectObject



781
782
783
# File 'lib/http-access2.rb', line 781

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

#to_sObject



777
778
779
# File 'lib/http-access2.rb', line 777

def to_s
  addr
end