Class: Traits
- Inherits:
-
Object
- Object
- Traits
- Defined in:
- lib/kittyverse/traits.rb
Class Method Summary collapse
Class Method Details
.[](key) ⇒ Object
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/kittyverse/traits.rb', line 271 def self.[]( key ) ## check for codes e.g. FU, PA, ... (or fu, pa,...). if key.size == 2 && key =~ /^[A-Za-z]{2}$/ TraitType.find_by_code( key ) ## check for codes e.g. FU00, FU01 ... (or fu00, fu01, ...) elsif key.size == 4 && key =~ /^[A-Za-z]{2}[0-9]{2}$/ Trait.find_by_code( key ) else if key.is_a? Symbol ## e.g. :body, :pattern, etc. t = TraitType.find_by_key( key ) t = Trait.find_by_name( key ) if t.nil? ## try trait name next - why? why not? t else ## assume string t = TraitType.find_by_name( key ) t = Trait.find_by_name( key ) if t.nil? ## try trait name next t end end end |
.each ⇒ Object
291 |
# File 'lib/kittyverse/traits.rb', line 291 def self.each() TraitType.each { |type| yield(type) }; end |
.each_with_index ⇒ Object
292 |
# File 'lib/kittyverse/traits.rb', line 292 def self.each_with_index() TraitType.each_with_index { |type,i| yield(type,i) }; end |