Class: IceCube::Validations::Until::Validation

Inherits:
Object
  • Object
show all
Defined in:
lib/ice_cube/validations/until.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time) ⇒ Validation

Returns a new instance of Validation.


22
23
24
# File 'lib/ice_cube/validations/until.rb', line 22

def initialize(time)
  @time = time
end

Instance Attribute Details

#timeObject (readonly)

Returns the value of attribute time


20
21
22
# File 'lib/ice_cube/validations/until.rb', line 20

def time
  @time
end

Instance Method Details

#build_hash(builder) ⇒ Object


44
45
46
# File 'lib/ice_cube/validations/until.rb', line 44

def build_hash(builder)
  builder[:until] = TimeUtil.serialize_time(time)
end

#build_ical(builder) ⇒ Object


48
49
50
# File 'lib/ice_cube/validations/until.rb', line 48

def build_ical(builder)
  builder['UNTIL'] << IcalBuilder.ical_utc_format(time)
end

#build_s(builder) ⇒ Object


39
40
41
42
# File 'lib/ice_cube/validations/until.rb', line 39

def build_s(builder)
  date = IceCube::I18n.l(time, format: IceCube.to_s_time_format)
  builder.piece(:until) << IceCube::I18n.t('ice_cube.until', date: date)
end

#dst_adjust?Boolean

Returns:

  • (Boolean)

30
31
32
# File 'lib/ice_cube/validations/until.rb', line 30

def dst_adjust?
  false
end

#typeObject


26
27
28
# File 'lib/ice_cube/validations/until.rb', line 26

def type
  :limit
end

#validate(step_time, start_time) ⇒ Object

Raises:


34
35
36
37
# File 'lib/ice_cube/validations/until.rb', line 34

def validate(step_time, start_time)
  end_time = TimeUtil.ensure_time(time, start_time, true)
  raise UntilExceeded if step_time > end_time
end