Sha256: f4dd1df2b0e85e2f8ab98a2205a9bf9ed75fcdd60fdab01ea73137e0f5d2e8df

Contents?: true

Size: 711 Bytes

Versions: 8

Compression:

Stored size: 711 Bytes

Contents

class Card
  module Set
    module Helpers
      def shortname
        parts = name.split "::"
        first = 2 # shortname eliminates Card::Set
        pattern_code = parts[first].underscore.to_sym
        last = first + num_set_parts(pattern_code)
        parts[first..last].join "::"
      end

      def underscore
        shortname.tr(":", "_").underscore
      end

      # move to Set::Pattern?
      def num_set_parts pattern_code
        return 1 if pattern_code == :abstract

        Pattern.find(pattern_code).anchor_parts_count
      end

      def abstract_set?
        name =~ /^Card::Set::Abstract::/
      end

      def all_set?
        name =~ /^Card::Set::All::/
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
card-1.99.1 lib/card/set/helpers.rb
card-1.99.0 lib/card/set/helpers.rb
card-1.98.3 lib/card/set/helpers.rb
card-1.98.2 lib/card/set/helpers.rb
card-1.98.1 lib/card/set/helpers.rb
card-1.98.0 lib/card/set/helpers.rb
card-1.97.0.1 lib/card/set/helpers.rb
card-1.97.0 lib/card/set/helpers.rb