Sha256: 69af9a2277c78aa4e6a1b4b847594ffa0a1d72591f9d80e80119a46522159a6a

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

# -*- encoding : utf-8 -*-
require_dependency 'card/env'

require 'smart_name'

class Card
  class Name < SmartName

    self.params  = Card::Env # yuck!
    self.session = proc { Card::Auth.current.name }
    self.banned_array = ['/']

    def star?
      simple? and '*' == s[0,1]
    end

    def rstar?
      right and '*' == right[0,1]
    end

    def trait_name? *traitlist
      junction? && begin
        right_key = right_name.key
        !!traitlist.find do |codename|
          card_id = Card::Codename[ codename ] and card = Card.fetch( card_id, :skip_modules=>true, :skip_virtual=>true ) and
            card.key == right_key
        end
      end
    end

    def trait_name tag_code
      card_id = Card::Codename[ tag_code ] and card = Card.fetch( card_id, :skip_modules=>true, :skip_virtual=>true ) and
        [ self, card.cardname ].to_name
    end

    def trait tag_code
      name = trait_name( tag_code )
      name ? name.s : ( raise Card::NotFound, "unknown codename: #{tag_code}" )
    end

    def code
      Card::Codename[ Card.fetch_id self ]
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
card-1.15.7 lib/card/name.rb
card-1.15.6 lib/card/name.rb
card-1.15.5 lib/card/name.rb
card-1.15.4 lib/card/name.rb
card-1.15.3 lib/card/name.rb