Class: Axiom::Attribute::Numeric
- Inherits:
-
Object
- Object
- Axiom::Attribute
- Object
- Axiom::Attribute::Numeric
- Includes:
- Axiom::Aggregate::Sum::Methods, Comparable
- Defined in:
- lib/axiom/attribute/numeric.rb
Overview
Represents a Numeric value in a relation tuple
Constant Summary collapse
- DEFAULT_SIZE =
(-::Float::INFINITY..::Float::INFINITY).freeze
Instance Attribute Summary collapse
-
#size ⇒ Range<::Numeric>
readonly
The Numeric range for a valid value.
Attributes inherited from Axiom::Attribute
Class Method Summary collapse
-
.primitive ⇒ Class<::Numeric>
The Numeric primitive.
Instance Method Summary collapse
-
#initialize(_name, _options = EMPTY_HASH) ⇒ undefined
constructor
private
Initialize a Numeric Attribute.
-
#valid_value?(value) ⇒ Boolean
Test if the value matches the attribute constraints.
Methods included from Comparable
Methods included from Function::Predicate::GreaterThan::Methods
Methods included from Function::Predicate::GreaterThanOrEqualTo::Methods
Methods included from Function::Predicate::LessThan::Methods
Methods included from Function::Predicate::LessThanOrEqualTo::Methods
Methods included from Axiom::Aggregate::Minimum::Methods
Methods included from Axiom::Aliasable
Methods included from Axiom::Aggregate::Maximum::Methods
Methods included from Axiom::Aggregate::Mean::Methods
Methods included from Axiom::Aggregate::Variance::Methods
Methods included from Axiom::Aggregate::StandardDeviation::Methods
Methods included from Axiom::Aggregate::Sum::Methods
Methods included from Function::Predicate::Equality::Methods
Methods included from Function::Predicate::Exclusion::Methods
Methods included from Function::Predicate::Inequality::Methods
Methods included from Function::Predicate::Inclusion::Methods
Methods included from Axiom::Aggregate::Count::Methods
Methods inherited from Axiom::Attribute
#call, coerce, infer_type, name_from, #rename, #required?, #type, #valid_primitive?
Methods included from Visitable
Constructor Details
#initialize(_name, _options = EMPTY_HASH) ⇒ undefined
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a Numeric Attribute
52 53 54 55 |
# File 'lib/axiom/attribute/numeric.rb', line 52 def initialize(_name, = EMPTY_HASH) super @size = @options.fetch(:size, self.class::DEFAULT_SIZE).to_inclusive end |
Instance Attribute Details
#size ⇒ Range<::Numeric> (readonly)
The Numeric range for a valid value
24 25 26 |
# File 'lib/axiom/attribute/numeric.rb', line 24 def size @size end |
Class Method Details
.primitive ⇒ Class<::Numeric>
The Numeric primitive
34 35 36 |
# File 'lib/axiom/attribute/numeric.rb', line 34 def self.primitive ::Numeric end |
Instance Method Details
#valid_value?(value) ⇒ Boolean
Test if the value matches the attribute constraints
68 69 70 |
# File 'lib/axiom/attribute/numeric.rb', line 68 def valid_value?(value) valid_or_optional?(value) { super && size.cover?(value) } end |