Files
Basalt2/node_modules/shiki/samples/ruby.sample
Robert Jelic 31787b0e9b Fix
2025-02-16 18:04:24 +01:00

21 lines
541 B
Plaintext

class LotteryTicket
NUMERIC_RANGE = 1..25
attr_reader :picks, :purchased
def initialize( *picks )
if picks.length != 3
raise ArgumentError, "three numbers must be picked"
elsif picks.uniq.length != 3
raise ArgumentError, "the three picks must be different numbers"
elsif picks.detect { |p| not NUMERIC_RANGE === p }
raise ArgumentError, "the three picks must be numbers between 1 and 25"
end
@picks = picks
@purchased = Time.now
end
end
# From https://poignant.guide/book/chapter-5.html