Module: Card::Set::Pattern::ClassMethods
- Included in:
- Base
- Defined in:
- card/lib/card/set/pattern/class_methods.rb
Overview
methods for Set::Pattern classes
Instance Attribute Summary collapse
-
#anchor_parts_count ⇒ Object
-
#anchorless ⇒ Object
Returns the value of attribute anchorless.
-
#assigns_type ⇒ Object
Returns the value of attribute assigns_type.
-
#compound_only ⇒ Object
Returns the value of attribute compound_only.
-
#pattern_code ⇒ Object
Returns the value of attribute pattern_code.
Instance Method Summary collapse
-
#anchorless? ⇒ Boolean
-
#compound_only? ⇒ Boolean
-
#generic_label ⇒ Object
label for set pattern if no anchor is given.
-
#module_key(anchor_codes) ⇒ Object
-
#new(card) ⇒ Object
-
#pattern ⇒ Object
TODO: change to #name or #pattern_name.
-
#pattern_applies?(card) ⇒ Boolean
-
#pattern_id ⇒ Object
-
#register(pattern_code, opts = {}) ⇒ Object
Instance Attribute Details
#anchor_parts_count ⇒ Object
41 42 43 |
# File 'card/lib/card/set/pattern/class_methods.rb', line 41 def anchor_parts_count @anchor_parts_count ||= (anchorless? ? 0 : 1) end |
#anchorless ⇒ Object
Returns the value of attribute anchorless.
6 7 8 |
# File 'card/lib/card/set/pattern/class_methods.rb', line 6 def anchorless @anchorless end |
#assigns_type ⇒ Object
Returns the value of attribute assigns_type.
6 7 8 |
# File 'card/lib/card/set/pattern/class_methods.rb', line 6 def assigns_type @assigns_type end |
#compound_only ⇒ Object
Returns the value of attribute compound_only.
6 7 8 |
# File 'card/lib/card/set/pattern/class_methods.rb', line 6 def compound_only @compound_only end |
#pattern_code ⇒ Object
Returns the value of attribute pattern_code.
6 7 8 |
# File 'card/lib/card/set/pattern/class_methods.rb', line 6 def pattern_code @pattern_code end |
Instance Method Details
#anchorless? ⇒ Boolean
24 25 26 |
# File 'card/lib/card/set/pattern/class_methods.rb', line 24 def anchorless? anchorless end |
#compound_only? ⇒ Boolean
20 21 22 |
# File 'card/lib/card/set/pattern/class_methods.rb', line 20 def compound_only? compound_only == true end |
#generic_label ⇒ Object
label for set pattern if no anchor is given
53 54 55 |
# File 'card/lib/card/set/pattern/class_methods.rb', line 53 def generic_label label nil end |
#module_key(anchor_codes) ⇒ Object
45 46 47 48 49 50 |
# File 'card/lib/card/set/pattern/class_methods.rb', line 45 def module_key anchor_codes return pattern_code.to_s.camelize if anchorless? return unless anchor_codes # not all anchors have codenames ([pattern_code] + anchor_codes).map { |code| code.to_s.camelize }.join "::" end |
#new(card) ⇒ Object
9 10 11 |
# File 'card/lib/card/set/pattern/class_methods.rb', line 9 def new card super if pattern_applies? card end |
#pattern ⇒ Object
TODO: change to #name or #pattern_name
33 34 35 |
# File 'card/lib/card/set/pattern/class_methods.rb', line 33 def pattern pattern_id.cardname end |
#pattern_applies?(card) ⇒ Boolean
37 38 39 |
# File 'card/lib/card/set/pattern/class_methods.rb', line 37 def pattern_applies? card compound_only? ? card.name.compound? : true end |
#pattern_id ⇒ Object
28 29 30 |
# File 'card/lib/card/set/pattern/class_methods.rb', line 28 def pattern_id pattern_code.card_id end |
#register(pattern_code, opts = {}) ⇒ Object
13 14 15 16 17 18 |
# File 'card/lib/card/set/pattern/class_methods.rb', line 13 def register pattern_code, opts={} self.pattern_code = pattern_code Pattern.concrete.insert opts.delete(:index).to_i, self self.anchorless = !respond_to?(:anchor_name) opts.each { |key, val| send "#{key}=", val } end |