class TZInfo::TZDataRule

:nodoc:
A rule in a RuleSet (a single Rule line in the tz data).

def activate(year)

def activate(year)
  # The following test ignores yearistype at present (currently unused in
  # the data. parse_type currently excepts on encountering a year type.
  if (@from == :min || @from <= year) && (@to == :max || @to >= year)                        
    TZDataActivatedRule.new(self, year)
  else
    nil
  end
end

def at_utc_time(year, utc_offset, std_offset)

def at_utc_time(year, utc_offset, std_offset)
  @at_time.to_utc(utc_offset, std_offset,
    year, @in_month, @on_day.to_absolute(year, @in_month))
end

def initialize(from, to, type, in_month, on_day, at_time, save, letter)

def initialize(from, to, type, in_month, on_day, at_time, save, letter)
  @from = parse_from(from)
  @to = parse_to(to)
  
  # replace a to of :only with the from year
  raise 'to cannot be only if from is minimum' if @to == :only && @from == :min
  @to = @from if @to == :only      
  
  @type = parse_type(type)
  @in_month = TZDataParser.parse_month(in_month)
  @on_day = TZDataDayOfMonth.new(on_day)
  @at_time = TZDataTime.new(at_time)
  @save = TZDataParser.parse_offset(save)
  @letter = parse_letter(letter)
end

def parse_from(from)

def parse_from(from)
  lower = from.downcase
  if lower =~ /^min/
    :min
  elsif lower =~ /^[0-9]+$/
    lower.to_i
  else
    raise "Invalid from: #{from}"
  end
end

def parse_letter(letter)

def parse_letter(letter)
  if letter == '-'
    nil
  else
    letter
  end
end

def parse_to(to)

def parse_to(to)
  lower = to.downcase
  if lower =~ /^max/
    :max
  elsif lower =~ /^o/
    :only
  elsif lower =~ /^[0-9]+$/
    lower.to_i
  else
    raise "Invalid to: #{to}"
  end
end

def parse_type(type)

def parse_type(type)
  raise "Unsupported rule type: #{type}" if type != '-'
  nil
end