Sha256: 23582e1cf534956609a636c58a166a5a9d1fe97326da482fae0cdb71e72c68cf

Contents?: true

Size: 998 Bytes

Versions: 13

Compression:

Stored size: 998 Bytes

Contents

  # -*- encoding : utf-8 -*-
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 Wagn::NotFound, "unknown codename: #{tag_code}" )
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
wagn-1.14.9 lib/card/name.rb
wagn-1.14.8 lib/card/name.rb
wagn-1.14.7 lib/card/name.rb
wagn-1.14.6 lib/card/name.rb
wagn-1.14.5 lib/card/name.rb
wagn-1.14.4 lib/card/name.rb
wagn-1.14.3 lib/card/name.rb
wagn-1.14.2 lib/card/name.rb
wagn-1.14.1 lib/card/name.rb
wagn-1.14.0 lib/card/name.rb
wagn-1.14.0.pre3 lib/card/name.rb
wagn-1.14.0.pre2 lib/card/name.rb
wagn-1.14.0.pre1 lib/card/name.rb