Class: Chadet::SecretCharacters

Inherits:
Object
  • Object
show all
Defined in:
lib/chadet.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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_setObject (readonly)

Returns the value of attribute chars_set.



194
195
196
# File 'lib/chadet.rb', line 194

def chars_set
  @chars_set
end

#max_hintObject (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_charsObject (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_charsObject

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_shuffleObject

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