lib/cat_ipsum/random.rb in cat_ipsum-0.2.1 vs lib/cat_ipsum/random.rb in cat_ipsum-0.2.2
- old
+ new
@@ -1,30 +1,32 @@
module CatIpsum
class Random
- def self.seed
- @seed ||= ::Random.new_seed
- end
+ class << self
+ def seed
+ @seed ||= ::Random.new_seed
+ end
- def self.seed=(value)
- @seed = value
- reset!
- value
- end
+ def seed=(value)
+ @seed = value
+ reset!
+ value
+ end
- def self.reset!
- @randomizer = randomize
- true
- end
+ def reset!
+ @randomizer = randomize
+ true
+ end
- def self.randomizer
- @randomizer ||= randomize
- end
+ def randomizer
+ @randomizer ||= randomize
+ end
- def self.randomize
- ::Random.new(seed)
- end
+ def randomize
+ ::Random.new(seed)
+ end
- def self.sample(array)
- array.shuffle(random: randomizer).take(3)
+ def sample(array, count: 3)
+ array.shuffle(random: randomizer).take(count)
+ end
end
end
end