Sha256: 6bfd7a15957f3d089f3130ab3a9b92fe09f536de7920d86fb818874d8e917678
Contents?: true
Size: 1.12 KB
Versions: 10
Compression:
Stored size: 1.12 KB
Contents
class Card class Name module NameVariants @@variant_methods = %i[capitalize singularize pluralize titleize downcase upcase swapcase reverse succ] @@variant_aliases = { capitalized: :capitalize, singular: :singularize, plural: :pluralize, title: :titleize } def vary variants variants.to_s.split(/[\s,]+/).inject(s) do |name, variant| variant = @@variant_aliases[variant.to_sym] || variant.to_sym @@variant_methods.include?(variant) ? name.send(variant) : name end end # @return [Card::Name] standardized based on card names def standard self.class.compose(parts.map { |part| Card.fetch_name(part) || part }) end def card Card.fetch self, new: {} end def card_id Lexicon.id self end # @return [Symbol] codename of card with name def codename Codename[card_id] end def codename_or_string codename || s end def alternative Card.generate_alternative_name self end end end end
Version data entries
10 entries across 10 versions & 1 rubygems