Class: PRRD::Database::Archive

Inherits:
Entity
  • Object
show all
Defined in:
lib/prrd/database/archive.rb

Overview

PRRD Database Archive class

Instance Attribute Summary

Attributes inherited from Entity

#data, #keys

Instance Method Summary collapse

Methods inherited from Entity

#method_missing, #validate_presence

Constructor Details

#initialize(values = nil) ⇒ Archive

Constructor



11
12
13
14
15
16
17
18
19
20
# File 'lib/prrd/database/archive.rb', line 11

def initialize(values = nil)
  @keys = [
    :cf,
    :xff,
    :steps,
    :rows
  ]

  super values
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class PRRD::Entity

Instance Method Details

#to_sObject

Transform to a RRA formatted string



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/prrd/database/archive.rb', line 23

def to_s
  fail 'Empty archive object' if @data.empty?

  validate_presence :cf, :xff, :steps, :rows

  chunks = ['RRA']

  @keys.each do |k|
    next unless @data.key?(k)
    chunks << @data[k]
  end

  chunks.join ':'
end