Class: UniParser::Proxy

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Proxy

Returns a new instance of Proxy.



5
6
7
8
# File 'lib/uni_parser/proxy.rb', line 5

def initialize(url)
  uri = URI url
  @host, @port = uri.host, uri.port
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



3
4
5
# File 'lib/uni_parser/proxy.rb', line 3

def host
  @host
end

#portObject (readonly)

Returns the value of attribute port.



3
4
5
# File 'lib/uni_parser/proxy.rb', line 3

def port
  @port
end

Instance Method Details

#freezeObject



10
11
12
# File 'lib/uni_parser/proxy.rb', line 10

def freeze
  @frozen_to = Time.now + freeze_time
end

#freeze_timeObject



14
15
16
# File 'lib/uni_parser/proxy.rb', line 14

def freeze_time
  UniParser.config.proxy_freeze_time || 1.minute
end

#frozen?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/uni_parser/proxy.rb', line 18

def frozen?
  Time.now < @frozen_to
end