Class: HTTPAccess2::Site

Inherits:
Object
  • Object
show all
Defined in:
lib/reap/vendor/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.



751
752
753
754
755
756
757
758
759
760
761
# File 'lib/reap/vendor/http-access2.rb', line 751

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.



748
749
750
# File 'lib/reap/vendor/http-access2.rb', line 748

def host
  @host
end

#portObject

Returns the value of attribute port.



749
750
751
# File 'lib/reap/vendor/http-access2.rb', line 749

def port
  @port
end

#schemeObject

:nodoc:



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

def scheme
  @scheme
end

Instance Method Details

#==(rhs) ⇒ Object



771
772
773
774
775
776
777
# File 'lib/reap/vendor/http-access2.rb', line 771

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

#addrObject



763
764
765
# File 'lib/reap/vendor/http-access2.rb', line 763

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

#inspectObject



783
784
785
# File 'lib/reap/vendor/http-access2.rb', line 783

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

#to_sObject



779
780
781
# File 'lib/reap/vendor/http-access2.rb', line 779

def to_s
  addr
end