lib/namna/generator.rb in namna-0.0.3 vs lib/namna/generator.rb in namna-0.0.4
- old
+ new
@@ -1,11 +1,17 @@
class Generator
- attr_reader :format
+ def self.random(length=(3..7).to_a.sample)
+ generate('?' * length)
+ end
- def initialize(format)
- @format = format.downcase
+ def self.human(length=(3..7).to_a.sample)
+ generate(('*#' * length).slice(rand(length), length))
end
- def generate
+ def self.format(format)
+ generate(format)
+ end
+
+ def self.generate(format)
format.split('').map(&:namna_sub).join('')
end
end