Class: BMC::TokenGenerator
- Inherits:
-
Object
- Object
- BMC::TokenGenerator
- Defined in:
- app/libs/bmc/token_generator.rb
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
- #alphabet ⇒ Object
- #call ⇒ Object
-
#initialize(options = {}) ⇒ TokenGenerator
constructor
A new instance of TokenGenerator.
- #size ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ TokenGenerator
Returns a new instance of TokenGenerator.
4 5 6 |
# File 'app/libs/bmc/token_generator.rb', line 4 def initialize( = {}) @options = end |
Class Attribute Details
.default_alphabet ⇒ Object
33 34 35 |
# File 'app/libs/bmc/token_generator.rb', line 33 def default_alphabet @default_alphabet ||= (0..9).to_a + ("a".."z").to_a + ("A".."Z").to_a end |
.default_size ⇒ Object
27 28 29 |
# File 'app/libs/bmc/token_generator.rb', line 27 def default_size @default_size ||= 64 end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
2 3 4 |
# File 'app/libs/bmc/token_generator.rb', line 2 def @options end |
Class Method Details
.call ⇒ Object
21 22 23 |
# File 'app/libs/bmc/token_generator.rb', line 21 def call(*) new(*).call end |
Instance Method Details
#alphabet ⇒ Object
12 13 14 |
# File 'app/libs/bmc/token_generator.rb', line 12 def alphabet [:alphabet] || self.class.default_alphabet end |
#call ⇒ Object
16 17 18 |
# File 'app/libs/bmc/token_generator.rb', line 16 def call (alphabet * size).sample(size).join end |
#size ⇒ Object
8 9 10 |
# File 'app/libs/bmc/token_generator.rb', line 8 def size [:size] || self.class.default_size end |