Class: VIN
- Inherits:
-
Object
- Object
- VIN
- Extended by:
- Mixins::Redis
- Defined in:
- lib/vin.rb,
lib/vin/id.rb,
lib/vin/config.rb,
lib/vin/request.rb,
lib/vin/version.rb,
lib/vin/response.rb,
lib/vin/generator.rb,
lib/vin/timestamp.rb,
lib/vin/lua_script.rb,
lib/vin/mixins/redis.rb
Defined Under Namespace
Modules: LuaScript, Mixins Classes: Config, Generator, Id, Request, Response, Timestamp
Constant Summary collapse
- VERSION =
"2.0.0".freeze
Constants included from Mixins::Redis
Mixins::Redis::DEFAULT_REDIS_URL
Instance Method Summary collapse
- #generate_id(data_type) ⇒ Object
- #generate_ids(data_type, count) ⇒ Object
- #generate_ids_from_timestamps(data_type, timestamps:) ⇒ Object
-
#initialize(config: nil) ⇒ VIN
constructor
A new instance of VIN.
Methods included from Mixins::Redis
Constructor Details
Instance Method Details
#generate_id(data_type) ⇒ Object
11 12 13 |
# File 'lib/vin.rb', line 11 def generate_id(data_type) generator.generate_id(data_type) end |
#generate_ids(data_type, count) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/vin.rb', line 15 def generate_ids(data_type, count) ids = [] # The Lua script can't always return as many IDs as you may want. So we loop # until we have the exact amount. while ids.length < count initial_id_count = ids.length ids += generator.generate_ids(data_type, count - ids.length) # Ensure the ids array keeps growing as infinite loop insurance return ids unless ids.length > initial_id_count end ids end |
#generate_ids_from_timestamps(data_type, timestamps:) ⇒ Object
28 29 30 |
# File 'lib/vin.rb', line 28 def (data_type, timestamps:) generator.(data_type, timestamps: ) end |