Class: SportDB::Team
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- SportDB::Team
- Defined in:
- lib/sportdb/models.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.create_from_ary!(teams) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/sportdb/models.rb', line 9 def self.create_from_ary!( teams ) teams.each do |values| ## key & title required attr = { :key => values[0], :title => values[1] } ## check for optional values values[2..-1].each do |value| if value.length == 3 ## assume its a tag (three latters) attr[ :tag ] = value else attr[ :title2 ] = value end end Team.create!( attr ) end # each team end |
Instance Method Details
#key ⇒ Object
31 32 33 34 35 36 37 38 |
# File 'lib/sportdb/models.rb', line 31 def key #todo/fix: generate_key w/ on save callback # generate key if necessary (for debugging only - should be not null field!) value = read_attribute(:key) value = "?#{title.downcase.gsub( /\s/, '_').gsub( /[^a-z0-9_]/, '*' )}?" if value.blank? value end |