Sha256: f524ed01ea23729c507e4e9740a10f772690cc17d67159c709e15be676fe75a8

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 KB

Contents

class Card
  module Mod
    class Loader
      class SetPatternLoader < Loader
        @module_type = :set_pattern

        def load_strategy_class load_strategy
          case load_strategy
          when :tmp_files
            LoadStrategy::PatternTmpFiles
          else # :eval
            LoadStrategy::Eval
          end
        end

        class Template < ModuleTemplate
          def to_const
            return Object if simple_load?

            Card::Set.const_get_or_set(@pattern.camelize) do
              Class.new(Card::Set::Pattern::Base)
            end
          end

          # correct line number for error messages
          def offset
            -5
          end

          private

          def auto_comment
            %(# Set Pattern: #{@pattern.camelize}\n#)
          end

          def module_chain
            "class Card::Set::#{@pattern.camelize} < Card::Set::Pattern::Base"
          end

          def preamble_bits
            [module_comment, module_chain, "cattr_accessor :options", "class << self"]
          end

          def postamble
            <<-RUBY
              end
              register "#{@pattern}".underscore.to_sym, (options || {})
            end
            RUBY
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
card-1.99.5 lib/card/mod/loader/set_pattern_loader.rb
card-1.99.4 lib/card/mod/loader/set_pattern_loader.rb
card-1.99.3 lib/card/mod/loader/set_pattern_loader.rb
card-1.99.2 lib/card/mod/loader/set_pattern_loader.rb