Module: Card::Mark
- Included in:
- Card
- Defined in:
- card/lib/card/mark.rb
Overview
Card::Mark provides class methods for Card to translate all different kind of card identifiers to card objects.
Instance Method Summary collapse
-
#cardish(cardish) ⇒ Object
translates marks (and other inputs) into a Card.
-
#id_or_name(parts) ⇒ Integer or Card::Name
translates various inputs into either an id or a name.
Instance Method Details
#cardish(cardish) ⇒ Object
translates marks (and other inputs) into a Card
9 10 11 12 13 14 15 |
# File 'card/lib/card/mark.rb', line 9 def cardish cardish if cardish.is_a? Card cardish else fetch cardish, new: {} end end |
#id_or_name(parts) ⇒ Integer or Card::Name
translates various inputs into either an id or a name.
20 21 22 23 24 |
# File 'card/lib/card/mark.rb', line 20 def id_or_name parts mark = parts.flatten mark = mark.first if mark.size <= 1 id_from_mark(mark) || Card::Name[mark] end |