Class: Ast::Crispr::Limit
- Inherits:
-
Object
- Object
- Ast::Crispr::Limit
- Defined in:
- lib/ast/crispr.rb
Defined Under Namespace
Classes: Constraint
Instance Attribute Summary collapse
-
#constraints ⇒ Object
readonly
Returns the value of attribute constraints.
Class Method Summary collapse
Instance Method Summary collapse
- #allows?(count) ⇒ Boolean
- #describe ⇒ Object
-
#initialize(limit = nil, **options) ⇒ Limit
constructor
A new instance of Limit.
Constructor Details
#initialize(limit = nil, **options) ⇒ Limit
Returns a new instance of Limit.
32 33 34 |
# File 'lib/ast/crispr.rb', line 32 def initialize(limit = nil, **) @constraints = normalize(limit, **) end |
Instance Attribute Details
#constraints ⇒ Object (readonly)
Returns the value of attribute constraints.
30 31 32 |
# File 'lib/ast/crispr.rb', line 30 def constraints @constraints end |
Class Method Details
.coerce(limit = nil, **options) ⇒ Object
25 26 27 |
# File 'lib/ast/crispr.rb', line 25 def coerce(limit = nil, **) limit.is_a?(self) ? limit : new(limit, **) end |
Instance Method Details
#allows?(count) ⇒ Boolean
36 37 38 |
# File 'lib/ast/crispr.rb', line 36 def allows?(count) constraints.all? { |constraint| constraint.predicate.call(count) } end |
#describe ⇒ Object
40 41 42 |
# File 'lib/ast/crispr.rb', line 40 def describe constraints.map(&:description).join(' and ') end |