Class: TZInfo::Data::TZDataRule

Inherits:
Object
  • Object
show all
Includes:
TZDataParserUtils
Defined in:
lib/tzinfo/data/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.



480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
# File 'lib/tzinfo/data/tzdataparser.rb', line 480

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 = parse_month(in_month)
  @on_day = TZDataDayOfMonth.new(on_day)
  @at_time = TZDataTime.new(at_time)
  @save = parse_offset(save)
  @letter = parse_letter(letter)
end

Instance Attribute Details

#at_timeObject (readonly)

Returns the value of attribute at_time.



476
477
478
# File 'lib/tzinfo/data/tzdataparser.rb', line 476

def at_time
  @at_time
end

#fromObject (readonly)

Returns the value of attribute from.



471
472
473
# File 'lib/tzinfo/data/tzdataparser.rb', line 471

def from
  @from
end

#in_monthObject (readonly)

Returns the value of attribute in_month.



474
475
476
# File 'lib/tzinfo/data/tzdataparser.rb', line 474

def in_month
  @in_month
end

#letterObject (readonly)

Returns the value of attribute letter.



478
479
480
# File 'lib/tzinfo/data/tzdataparser.rb', line 478

def letter
  @letter
end

#on_dayObject (readonly)

Returns the value of attribute on_day.



475
476
477
# File 'lib/tzinfo/data/tzdataparser.rb', line 475

def on_day
  @on_day
end

#saveObject (readonly)

Returns the value of attribute save.



477
478
479
# File 'lib/tzinfo/data/tzdataparser.rb', line 477

def save
  @save
end

#toObject (readonly)

Returns the value of attribute to.



472
473
474
# File 'lib/tzinfo/data/tzdataparser.rb', line 472

def to
  @to
end

#typeObject (readonly)

Returns the value of attribute type.



473
474
475
# File 'lib/tzinfo/data/tzdataparser.rb', line 473

def type
  @type
end

Instance Method Details

#activate(year) ⇒ Object



496
497
498
499
500
501
502
503
504
# File 'lib/tzinfo/data/tzdataparser.rb', line 496

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



506
507
508
509
# File 'lib/tzinfo/data/tzdataparser.rb', line 506

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