Class: Stupidedi::Schema::RepeatCount
- Defined in:
- lib/stupidedi/schema/repeat_count.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Bounded
Constant Summary collapse
- Once =
Class.new(Bounded) do def initialize @max = 1 end end.new
- Unbounded =
Class.new(RepeatCount) do include Comparable Infinity = 1.0/0.0 def include?(n) true end def exclude?(n) false end def <=>(n) Infinity <=> n end def inspect ">1" end end.new
Constructors collapse
Class Method Details
.bounded(n) ⇒ Object
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/stupidedi/schema/repeat_count.rb', line 66 def bounded(n) if n < 1 raise Exception::InvalidSchemaError, "n must be positive" elsif n == 1 RepeatCount::Once else RepeatCount::Bounded.new(n) end end |
.unbounded ⇒ Object
77 78 79 |
# File 'lib/stupidedi/schema/repeat_count.rb', line 77 def unbounded RepeatCount::Unbounded end |