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 = "# -*- encoding : utf-8 -*-\nclass \#{klass} < Card::Set::Pattern::Abstract\n cattr_accessor :options\n class << self\n# ~~ above autogenerated; below pulled from \#{from_file} ~~\n\n\#{File.read from_file}\n\n# ~~ below autogenerated; above pulled from \#{from_file} ~~\n end\n register \"\#{pattern_code}\", (options || {})\nend\n\n" File.write to_file, file_content to_file end |