Class: TTK::Fetchers::Server

Inherits:
Object
  • Object
show all
Includes:
DRb::DRbUndumped
Defined in:
lib/ttk/fetchers/Server.rb,
lib/ttk/fetchers/server/sender.rb

Defined Under Namespace

Classes: Sender

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service, repository) ⇒ Server

Returns a new instance of Server.



17
18
19
20
21
22
# File 'lib/ttk/fetchers/Server.rb', line 17

def initialize(service, repository)
  @service = service
  @repository = repository
  @resources_sent = []
  @mutex = Mutex.new
end

Instance Attribute Details

#repositoryObject (readonly)

Returns the value of attribute repository.



24
25
26
# File 'lib/ttk/fetchers/Server.rb', line 24

def repository
  @repository
end

Instance Method Details

#fetch(resource, recv) ⇒ Object



30
31
32
33
34
35
# File 'lib/ttk/fetchers/Server.rb', line 30

def fetch(resource, recv)
  sender = Sender.new(@repository + resource, recv)
  @mutex.synchronize { @resources_sent << sender }
  sender.send
  sender.stat
end

#resources_sentObject



26
27
28
# File 'lib/ttk/fetchers/Server.rb', line 26

def resources_sent
  @mutex.synchronize { @resources_sent.dup }
end

#uriObject



37
38
39
# File 'lib/ttk/fetchers/Server.rb', line 37

def uri
  @service.uri
end