From 6702a58851eed5dc5a8515eb75058a06782870b8 Mon Sep 17 00:00:00 2001 From: Stormwind Date: Mon, 23 Feb 2015 21:54:01 +0100 Subject: [PATCH] Add a storage This storage should contain the weighted data, before it it's used in the output classes. So we can create a timeline. Plus we have a nice place to store the weighted data. --- lib/rubella/storage.rb | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 lib/rubella/storage.rb diff --git a/lib/rubella/storage.rb b/lib/rubella/storage.rb new file mode 100644 index 0000000..4e90c50 --- /dev/null +++ b/lib/rubella/storage.rb @@ -0,0 +1,30 @@ +module Rubella + + # The Rubella::Storage holds the weighted data. + # Storages can be added to get a timeline. But the Storage has no concrete + # knowledge of time. + # The Storage can have a defined length. If new data is added, it will drop + # the oldest entries. + # + class Storage + attr_reader :data + attr_reader :length + + def initialize data, length = nil + @data = data + self.length = length + end + + # Defines the length of the Storage. + # Be careful, if your Storage has more entries, tha the new length, the + # oldest entries will immediately be dropped. + # + def length= length + @length = length + + # TODO drop entries, if more than new length + end + + end + +end \ No newline at end of file