Class: Egn::Generator
- Inherits:
-
Object
- Object
- Egn::Generator
- Defined in:
- lib/egn/generator.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.generate(options = {}) ⇒ Object
Convenience method.
Instance Method Summary collapse
-
#generate ⇒ Object
The generated EGN will be completely random if no options are given.
-
#initialize(options = {}) ⇒ Generator
constructor
A new instance of Generator.
Constructor Details
#initialize(options = {}) ⇒ Generator
Returns a new instance of Generator.
11 12 13 14 15 |
# File 'lib/egn/generator.rb', line 11 def initialize( = {}) validate!() set_defaults!() process! end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/egn/generator.rb', line 4 def @options end |
Class Method Details
Instance Method Details
#generate ⇒ Object
The generated EGN will be completely random if no options are given. options is a hash that may have the following keys: :year, :month, :day, :gender
19 20 21 22 23 24 25 26 |
# File 'lib/egn/generator.rb', line 19 def generate egn = format([:year]) + format([:month]) + format([:day]) + format([:region], 3) egn + Util.egn_checksum(egn).to_s end |