Class: VsTokenGenerator::Token
- Inherits:
-
Object
- Object
- VsTokenGenerator::Token
- Defined in:
- lib/vs_token_generator.rb
Constant Summary collapse
- @@charset =
setting initial value (optional)
%w{0 1 2 3 5 8 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z}- @@group_size =
5- @@length =
25
Instance Attribute Summary collapse
-
#group_size ⇒ Object
Returns the value of attribute group_size.
-
#length ⇒ Object
Returns the value of attribute length.
Instance Method Summary collapse
- #generate(token = raw_token) ⇒ Object
-
#initialize(params = {}) ⇒ Token
constructor
A new instance of Token.
- #raw_token ⇒ Object
Constructor Details
#initialize(params = {}) ⇒ Token
Returns a new instance of Token.
13 14 15 16 |
# File 'lib/vs_token_generator.rb', line 13 def initialize(params = {}) @length = params.fetch(:length, @@length) @group_size = params.fetch(:group_size, @@group_size) end |
Instance Attribute Details
#group_size ⇒ Object
Returns the value of attribute group_size.
11 12 13 |
# File 'lib/vs_token_generator.rb', line 11 def group_size @group_size end |
#length ⇒ Object
Returns the value of attribute length.
11 12 13 |
# File 'lib/vs_token_generator.rb', line 11 def length @length end |
Instance Method Details
#generate(token = raw_token) ⇒ Object
22 23 24 |
# File 'lib/vs_token_generator.rb', line 22 def generate(token=raw_token) pretty_token(token, @group_size) end |
#raw_token ⇒ Object
18 19 20 |
# File 'lib/vs_token_generator.rb', line 18 def raw_token (1..@length).map { random_char @@charset }.join end |