Class: Dogtag::Generator
- Inherits:
-
Object
- Object
- Dogtag::Generator
- Defined in:
- lib/dogtag/generator.rb
Instance Method Summary collapse
- #ids ⇒ Object
-
#initialize(data_type, count = 1) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(data_type, count = 1) ⇒ Generator
Returns a new instance of Generator.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/dogtag/generator.rb', line 3 def initialize(data_type, count = 1) unless data_type.is_a? Integer raise ArgumentError, 'data_type must be an integer' end unless Dogtag::DATA_TYPE_ALLOWED_RANGE.include? data_type raise ArgumentError, "data_type is outside the allowed range of #{Dogtag::DATA_TYPE_ALLOWED_RANGE}" end raise ArgumentError, 'count must be an integer' unless count.is_a? Integer raise ArgumentError, 'count must be a positive number' if count < 1 @data_type = data_type @count = count end |
Instance Method Details
#ids ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/dogtag/generator.rb', line 19 def ids response.sequence.map do |sequence| ( | shifted_logical_shard_id | shifted_data_type | (sequence << Dogtag::SEQUENCE_SHIFT) ) end end |