Sha256: 60e716c6426b5fcb3ca901c25fd7f8b7661ae0c7552ec2037ccd52b65253623e
Contents?: true
Size: 1.31 KB
Versions: 2
Compression:
Stored size: 1.31 KB
Contents
module Redistat class Key attr_accessor :scope attr_accessor :date attr_accessor :options def initialize(scope, label_name = nil, time_stamp = nil, options = {}) @options = default_options.merge(options || {}) @scope = scope self.label = label_name if !label_name.nil? self.date = time_stamp ||= Time.now end def default_options { :depth => :hour, :hashed_label => false } end def prefix key = "#{@scope}" key << "/#{label}" if !label.nil? key << ":" key end def date=(input) @date = (input.instance_of?(Redistat::Date)) ? input : Date.new(input) # Redistat::Date, not ::Date end def depth @options[:depth] end def label @label.name end def label_hash @label.hash end def label_groups @label.groups end def label=(input) @label = (input.instance_of?(Redistat::Label)) ? input : Label.create(input, @options) end def groups @groups ||= label_groups.map do |label_name| self.class.new(@scope, label_name, self.date, @options) end end def to_s(depth = nil) depth ||= @options[:depth] key = self.prefix key << @date.to_s(depth) key end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
redistat-0.1.1 | lib/redistat/key.rb |
redistat-0.1.0 | lib/redistat/key.rb |