Class: Ace::Idea::Atoms::IdeaIdFormatter
- Inherits:
-
Object
- Object
- Ace::Idea::Atoms::IdeaIdFormatter
- Defined in:
- lib/ace/idea/atoms/idea_id_formatter.rb
Overview
Generates and formats raw b36ts IDs for ideas. Ideas use raw 6-char b36ts IDs without type markers. Example: “8ppq7w” (no “.t.” or “.i.” separator)
Class Method Summary collapse
-
.decode_time(id) ⇒ Time
Decode a raw idea ID to the time it was created.
-
.generate(time = Time.now.utc) ⇒ String
Generate a new raw 6-char b36ts ID for an idea.
-
.valid?(id) ⇒ Boolean
Validate that a string is a valid raw idea ID.
Class Method Details
.decode_time(id) ⇒ Time
Decode a raw idea ID to the time it was created
31 32 33 |
# File 'lib/ace/idea/atoms/idea_id_formatter.rb', line 31 def self.decode_time(id) Ace::B36ts.decode(id) end |
.generate(time = Time.now.utc) ⇒ String
Generate a new raw 6-char b36ts ID for an idea
15 16 17 |
# File 'lib/ace/idea/atoms/idea_id_formatter.rb', line 15 def self.generate(time = Time.now.utc) Ace::B36ts.encode(time, format: :"2sec") end |
.valid?(id) ⇒ Boolean
Validate that a string is a valid raw idea ID
22 23 24 25 26 |
# File 'lib/ace/idea/atoms/idea_id_formatter.rb', line 22 def self.valid?(id) return false if id.nil? || id.empty? Ace::B36ts.valid?(id) end |