Module: RubbishCollection

Defined in:
lib/rubbish_collection.rb,
lib/rubbish_collection/version.rb,
lib/rubbish_collection/rushmoor.rb,
lib/rubbish_collection/redbridge.rb,
lib/rubbish_collection/southwark.rb

Defined Under Namespace

Classes: CollectionTime, CollectionTimes, RedbridgeAdapter, RushmoorAdapter, SouthwarkAdapter, UnknownAdapter

Constant Summary collapse

VERSION =
"0.0.3"

Class Method Summary collapse

Class Method Details

.adapter_for(local_authority) ⇒ Object



88
89
90
91
92
# File 'lib/rubbish_collection.rb', line 88

def self.adapter_for local_authority
  adapter = adapters[local_authority.map_it_id]
  adapter.load if adapter.respond_to? :load
  adapter.new local_authority
end

.adaptersObject



84
85
86
# File 'lib/rubbish_collection.rb', line 84

def self.adapters
  @@adapters ||= Hash.new UnknownAdapter
end

.register_adapter(map_it_id, adapter) ⇒ Object



94
95
96
# File 'lib/rubbish_collection.rb', line 94

def self.register_adapter map_it_id, adapter
  adapters[map_it_id] = adapter
end

.times_at_address(address) ⇒ Object



72
73
74
75
76
77
78
79
80
81
82
# File 'lib/rubbish_collection.rb', line 72

def self.times_at_address address
  pc = address.postcode
  local_authority = LocalAuthority::LocalAuthority.find_by_postcode pc
  times = CollectionTimes.new
  return times if local_authority.nil?
  adaptor = adapter_for local_authority
  adaptor.collection_times_at(address).each do |t|
    times << t
  end
  times
end