class RacingAssociation

OBRA, WSBA, USA Cycling, etc … Many defaults. Override in environment.rb. Stored in ::current constant. bar_point_schedule should be stored in the database with the BAR?

cx_memberships? Offers cyclocross memberships eager_match_on_license? Trust license number in results? Use it to match People instead of name. search_results_limit: Limit number of people, teams, etc. returned in search

Attributes

person[RW]
rental_numbers[RW]

Public Class Methods

current() click to toggle source
# File app/models/racing_association.rb, line 48
def self.current
  @current ||= RacingAssociation.first || RacingAssociation.create
end
current=(value) click to toggle source
# File app/models/racing_association.rb, line 52
def self.current=(value)
  @current = value
end

Public Instance Methods

cyclocross_season?() click to toggle source
# File app/models/racing_association.rb, line 104
def cyclocross_season?
  RacingAssociation.current.today >= cyclocross_season_start.to_date && RacingAssociation.current.today <= cyclocross_season_end.to_date
end
cyclocross_season_end() click to toggle source
# File app/models/racing_association.rb, line 112
def cyclocross_season_end
  Time.zone.local(Time.zone.now.year, 12, 5).end_of_day
end
cyclocross_season_start() click to toggle source
# File app/models/racing_association.rb, line 108
def cyclocross_season_start
  Time.zone.local(Time.zone.now.year, 9, 2).beginning_of_day
end
effective_today() click to toggle source
# File app/models/racing_association.rb, line 91
def effective_today
  Date.new(effective_year)
end
effective_year() click to toggle source

“Membership year.” Used for race number export, schedule, and renewals. Returns current year until December. On and after December 1, returns the next year.

# File app/models/racing_association.rb, line 73
def effective_year
  if next_year_start_at
    if Time.zone.now < next_year_start_at
      return Time.zone.now.year
    elsif Time.zone.now >= next_year_start_at
      return Time.zone.now.year + 1
    elsif 1.year.from_now > next_year_start_at && Time.zone.now.month >= 12
      return Time.zone.now.year + 1
    end
  else
    if Time.zone.now.month == 12
      return Time.zone.now.year + 1
    end
  end
  
  Time.zone.now.year
end
next_year() click to toggle source

Time.zone.today.year + 1 unless now is set.

# File app/models/racing_association.rb, line 96
def next_year
  if effective_year == Time.zone.now.year
    effective_year + 1
  else
    effective_year
  end
end
priority_country_options() click to toggle source
# File app/models/racing_association.rb, line 116
def priority_country_options
  if country_code == "US"
    [ ['United States', 'US'], ['Canada', 'CA'] ]
  else
    [ ['Canada', 'CA'], ['United States', 'US'] ]
  end
end
to_s() click to toggle source
# File app/models/racing_association.rb, line 124
def to_s
  "#<RacingAssociation #{short_name} #{name}>"
end
today() click to toggle source

Returns now.beginning_of_day, which is the same as Time.zone.today

# File app/models/racing_association.rb, line 62
def today
  Time.zone.now.to_date
end
year() click to toggle source

Returns now.year, which is the same as Time.zone.today.

# File app/models/racing_association.rb, line 67
def year
  Time.zone.now.year
end