Class: TZInfo::TZDataRule

Inherits:
Object
  • Object
show all
Defined in:
lib/tzinfo/tzdataparser.rb

Overview

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(from, to, type, in_month, on_day, at_time, save, letter) ⇒ TZDataRule

Returns a new instance of TZDataRule.



412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
# File 'lib/tzinfo/tzdataparser.rb', line 412

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

Instance Attribute Details

#at_timeObject (readonly)

Returns the value of attribute at_time.



408
409
410
# File 'lib/tzinfo/tzdataparser.rb', line 408

def at_time
  @at_time
end

#fromObject (readonly)

:nodoc:



403
404
405
# File 'lib/tzinfo/tzdataparser.rb', line 403

def from
  @from
end

#in_monthObject (readonly)

Returns the value of attribute in_month.



406
407
408
# File 'lib/tzinfo/tzdataparser.rb', line 406

def in_month
  @in_month
end

#letterObject (readonly)

Returns the value of attribute letter.



410
411
412
# File 'lib/tzinfo/tzdataparser.rb', line 410

def letter
  @letter
end

#on_dayObject (readonly)

Returns the value of attribute on_day.



407
408
409
# File 'lib/tzinfo/tzdataparser.rb', line 407

def on_day
  @on_day
end

#saveObject (readonly)

Returns the value of attribute save.



409
410
411
# File 'lib/tzinfo/tzdataparser.rb', line 409

def save
  @save
end

#toObject (readonly)

Returns the value of attribute to.



404
405
406
# File 'lib/tzinfo/tzdataparser.rb', line 404

def to
  @to
end

#typeObject (readonly)

Returns the value of attribute type.



405
406
407
# File 'lib/tzinfo/tzdataparser.rb', line 405

def type
  @type
end

Instance Method Details

#activate(year) ⇒ Object



428
429
430
431
432
433
434
435
436
# File 'lib/tzinfo/tzdataparser.rb', line 428

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

#at_utc_time(year, utc_offset, std_offset) ⇒ Object



438
439
440
441
# File 'lib/tzinfo/tzdataparser.rb', line 438

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