Class: Card::Set::Pattern
- Inherits:
-
Object
- Object
- Card::Set::Pattern
- Defined in:
- lib/card/set_pattern.rb
Defined Under Namespace
Classes: Abstract
Class Method Summary collapse
- .card_keys ⇒ Object
- .find(pattern_code) ⇒ Object
- .write_tmp_file(pattern_code, from_file, seq) ⇒ Object
Class Method Details
.card_keys ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/card/set_pattern.rb', line 9 def card_keys @card_keys ||= Card.set_patterns.inject({}) do |hash, set_pattern| card_key = Card.quick_fetch(set_pattern.pattern_code.to_sym).key hash[card_key] = true hash end end |
.find(pattern_code) ⇒ Object
5 6 7 |
# File 'lib/card/set_pattern.rb', line 5 def find pattern_code Card.set_patterns.find { |sub| sub.pattern_code == pattern_code } end |
.write_tmp_file(pattern_code, from_file, seq) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/card/set_pattern.rb', line 18 def write_tmp_file pattern_code, from_file, seq to_file = "#{Card.paths['tmp/set_pattern'].first}/" \ "#{seq}-#{pattern_code}.rb" klass = "Card::Set::#{pattern_code.camelize}" file_content = <<EOF # -*- encoding : utf-8 -*- class #{klass} < Card::Set::Pattern::Abstract cattr_accessor :options class << self # ~~ above autogenerated; below pulled from #{from_file} ~~ #{File.read from_file} # ~~ below autogenerated; above pulled from #{from_file} ~~ end register "#{pattern_code}", (options || {}) end EOF File.write to_file, file_content to_file end |