Class: IceCube::Validations::Count::Validation
- Inherits:
-
Object
- Object
- IceCube::Validations::Count::Validation
- Defined in:
- lib/ice_cube/validations/count.rb
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#rule ⇒ Object
readonly
Returns the value of attribute rule.
Instance Method Summary collapse
- #build_hash(builder) ⇒ Object
- #build_ical(builder) ⇒ Object
- #build_s(builder) ⇒ Object
-
#initialize(count, rule) ⇒ Validation
constructor
A new instance of Validation.
- #type ⇒ Object
- #validate(time, schedule) ⇒ Object
Constructor Details
#initialize(count, rule) ⇒ Validation
Returns a new instance of Validation.
23 24 25 26 |
# File 'lib/ice_cube/validations/count.rb', line 23 def initialize(count, rule) @count = count @rule = rule end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
21 22 23 |
# File 'lib/ice_cube/validations/count.rb', line 21 def count @count end |
#rule ⇒ Object (readonly)
Returns the value of attribute rule.
21 22 23 |
# File 'lib/ice_cube/validations/count.rb', line 21 def rule @rule end |
Instance Method Details
#build_hash(builder) ⇒ Object
40 41 42 |
# File 'lib/ice_cube/validations/count.rb', line 40 def build_hash(builder) builder[:count] = count end |
#build_ical(builder) ⇒ Object
44 45 46 |
# File 'lib/ice_cube/validations/count.rb', line 44 def build_ical(builder) builder['COUNT'] << count end |
#build_s(builder) ⇒ Object
36 37 38 |
# File 'lib/ice_cube/validations/count.rb', line 36 def build_s(builder) builder.piece(:count) << count end |
#type ⇒ Object
28 29 30 |
# File 'lib/ice_cube/validations/count.rb', line 28 def type :limit end |
#validate(time, schedule) ⇒ Object
32 33 34 |
# File 'lib/ice_cube/validations/count.rb', line 32 def validate(time, schedule) raise CountExceeded if rule.uses && rule.uses >= count end |