Class: HTTPAccess2::Site

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



1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
# File 'lib/rss-client/http-access2.rb', line 1182

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.



1179
1180
1181
# File 'lib/rss-client/http-access2.rb', line 1179

def host
  @host
end

#portObject

Returns the value of attribute port.



1180
1181
1182
# File 'lib/rss-client/http-access2.rb', line 1180

def port
  @port
end

#schemeObject

:nodoc:



1178
1179
1180
# File 'lib/rss-client/http-access2.rb', line 1178

def scheme
  @scheme
end

Instance Method Details

#==(rhs) ⇒ Object



1204
1205
1206
1207
1208
1209
1210
# File 'lib/rss-client/http-access2.rb', line 1204

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

#addrObject



1196
1197
1198
# File 'lib/rss-client/http-access2.rb', line 1196

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

#inspectObject



1216
1217
1218
# File 'lib/rss-client/http-access2.rb', line 1216

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

#to_sObject



1212
1213
1214
# File 'lib/rss-client/http-access2.rb', line 1212

def to_s
  addr
end