module Ages

Public Instance Methods

ages() click to toggle source

Return Range

# File lib/ages.rb, line 3
def ages
  ages_begin..ages_end
end
ages=(value) click to toggle source

Accepts an age Range like 10..18, or a String like 10-18

# File lib/ages.rb, line 8
def ages=(value)
  case value
  when Range
    self.ages_begin = value.begin
    self.ages_end = value.end
  else
    age_split = value.strip.split('-')
    self.ages_begin = age_split[0].to_i unless age_split[0].nil?
    self.ages_end = age_split[1].to_i unless age_split[1].nil?
  end
end