Class: Chadet::SecretCharacters
- Inherits:
-
Object
- Object
- Chadet::SecretCharacters
- Defined in:
- lib/chadet.rb
Instance Attribute Summary collapse
-
#chars_set ⇒ Object
readonly
Returns the value of attribute chars_set.
-
#max_hint ⇒ Object
readonly
Returns the value of attribute max_hint.
-
#num_of_chars ⇒ Object
readonly
Returns the value of attribute num_of_chars.
-
#secret_chars ⇒ Object
Returns the value of attribute secret_chars.
Instance Method Summary collapse
-
#do_shuffle ⇒ Object
Shuffle a set of number from 0-9.
-
#initialize(chars_set, num_of_chars) ⇒ SecretCharacters
constructor
default chars = “0123456789” and default num = 4, see option parser.
Constructor Details
#initialize(chars_set, num_of_chars) ⇒ SecretCharacters
default chars = “0123456789” and default num = 4, see option parser.
198 199 200 201 202 |
# File 'lib/chadet.rb', line 198 def initialize chars_set, num_of_chars @num_of_chars = num_of_chars @chars_set = chars_set @secret_chars = do_shuffle end |
Instance Attribute Details
#chars_set ⇒ Object (readonly)
Returns the value of attribute chars_set.
194 195 196 |
# File 'lib/chadet.rb', line 194 def chars_set @chars_set end |
#max_hint ⇒ Object (readonly)
Returns the value of attribute max_hint.
194 195 196 |
# File 'lib/chadet.rb', line 194 def max_hint @max_hint end |
#num_of_chars ⇒ Object (readonly)
Returns the value of attribute num_of_chars.
194 195 196 |
# File 'lib/chadet.rb', line 194 def num_of_chars @num_of_chars end |
#secret_chars ⇒ Object
Returns the value of attribute secret_chars.
195 196 197 |
# File 'lib/chadet.rb', line 195 def secret_chars @secret_chars end |
Instance Method Details
#do_shuffle ⇒ Object
Shuffle a set of number from 0-9
205 206 207 208 209 |
# File 'lib/chadet.rb', line 205 def do_shuffle prep_chars = @chars_set.chars.to_a.shuffle secret_chars = prep_chars[0, @num_of_chars].join.to_s return secret_chars end |