Class: Profit::Key
- Inherits:
-
Object
- Object
- Profit::Key
- Defined in:
- lib/profit/key.rb
Class Method Summary collapse
Instance Method Summary collapse
- #full ⇒ Object
-
#initialize(key) ⇒ Key
constructor
A new instance of Key.
- #metrics ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(key) ⇒ Key
Returns a new instance of Key.
16 17 18 |
# File 'lib/profit/key.rb', line 16 def initialize(key) @key = key end |
Class Method Details
.all ⇒ Object
7 8 9 |
# File 'lib/profit/key.rb', line 7 def all redis.smembers("profit:keys").map { |key| new(key.split(":").last) } end |
Instance Method Details
#full ⇒ Object
28 29 30 |
# File 'lib/profit/key.rb', line 28 def full "profit:metric:#{@key}" end |
#metrics ⇒ Object
24 25 26 |
# File 'lib/profit/key.rb', line 24 def metrics self.class.redis.lrange(full, 0, -1).map {|key_data| Metric.new(key_data)}.reverse end |
#to_s ⇒ Object
20 21 22 |
# File 'lib/profit/key.rb', line 20 def to_s @key end |