class Decko_cards
Attributes
cards[R]
Public Class Methods
new(aces=:h)
click to toggle source
# File lib/decko_cards.rb, line 4 def initialize(aces=:h) @cards = gen(aces) end
Public Instance Methods
deal()
click to toggle source
# File lib/decko_cards.rb, line 8 def deal @cards.shuffle!.pop end
Private Instance Methods
ace_make(aces)
click to toggle source
# File lib/decko_cards.rb, line 28 def ace_make(aces) r = ranks if aces == :l r['Ace']= 1 elsif aces == :w r.each { |c, v| r[c]=Array(v) } r['Ace'] << 1 end r end
deck_make(list, hash)
click to toggle source
# File lib/decko_cards.rb, line 41 def deck_make(list, hash) d = [] for s in list hash.each { |r, v| d << { :name =>"#{r} of #{s}", :suit =>s.to_sym, :rank => r.to_sym, :value => v } } end d end
gen(aces)
click to toggle source
# File lib/decko_cards.rb, line 23 def gen(aces) r = ace_make(aces) deck_make(suits, r) end
ranks()
click to toggle source
# File lib/decko_cards.rb, line 17 def ranks @ranks = {'Two'=>2, 'Three'=>3, 'Four'=>4, 'Five'=>5, 'Six'=>6, 'Seven'=>7, 'Eight'=>8, 'Nine'=>9, 'Ten'=>10, 'Jack'=>10, 'Queen'=>10, 'King'=>10, 'Ace'=>11} end
suits()
click to toggle source
# File lib/decko_cards.rb, line 13 def suits @suits = ['Spades', 'Diamonds', 'Clubs', 'Hearts'] end