Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,11 @@
module Fruits
APPLE = 0
BANANA = 1
CHERRY = 2
end
# It is possible to use a symbol if the value is unrelated.
FRUITS = [:apple, :banana, :cherry]
val = :banana
FRUITS.include?(val) #=> true

View file

@ -0,0 +1,12 @@
module Card
# constants
SUITS = %i(Clubs Hearts Spades Diamonds)
SUIT_VALUE = SUITS.each_with_index.to_h # version 2.1+
# SUIT_VALUE = Hash[ SUITS.each_with_index.to_a ] # before it
#=> {:Clubs=>0, :Hearts=>1, :Spades=>2, :Diamonds=>3}
PIPS = %i(2 3 4 5 6 7 8 9 10 Jack Queen King Ace)
PIP_VALUE = PIPS.each.with_index(2).to_h # version 2.1+
# PIP_VALUE = Hash[ PIPS.each.with_index(2).to_a ] # before it
#=> {:"2"=>2, :"3"=>3, :"4"=>4, :"5"=>5, :"6"=>6, :"7"=>7, :"8"=>8, :"9"=>9, :"10"=>10, :Jack=>11, :Queen=>12, :King=>13, :Ace=>14}
end