Class: TokenChain::Generator
- Inherits:
-
Object
- Object
- TokenChain::Generator
- Defined in:
- lib/token_chain/generator.rb
Instance Attribute Summary collapse
-
#anchor_code ⇒ Object
readonly
Returns the value of attribute anchor_code.
-
#codes ⇒ Object
readonly
Returns the value of attribute codes.
Instance Method Summary collapse
- #generate(quantity = 1) ⇒ Object
-
#initialize(anchor_code, last_code = nil) ⇒ Generator
constructor
A new instance of Generator.
- #sha ⇒ Object
Constructor Details
#initialize(anchor_code, last_code = nil) ⇒ Generator
Returns a new instance of Generator.
7 8 9 10 11 |
# File 'lib/token_chain/generator.rb', line 7 def initialize anchor_code, last_code=nil @anchor_code = anchor_code @last_code = last_code @codes = [] end |
Instance Attribute Details
#anchor_code ⇒ Object (readonly)
Returns the value of attribute anchor_code.
5 6 7 |
# File 'lib/token_chain/generator.rb', line 5 def anchor_code @anchor_code end |
#codes ⇒ Object (readonly)
Returns the value of attribute codes.
5 6 7 |
# File 'lib/token_chain/generator.rb', line 5 def codes @codes end |
Instance Method Details
#generate(quantity = 1) ⇒ Object
13 14 15 16 |
# File 'lib/token_chain/generator.rb', line 13 def generate quantity=1 codes = make_new_codes quantity quantity > 1 ? codes : codes.last end |
#sha ⇒ Object
18 19 20 |
# File 'lib/token_chain/generator.rb', line 18 def sha @sha ||= Digest::SHA2.new end |