Class: PgGraph::Data::Dimension
- Inherits:
-
Object
- Object
- PgGraph::Data::Dimension
- Defined in:
- lib/pg_graph/data/dimension.rb
Overview
Dimension of the node (corresponding kind shown in parenthesis):
0 A single value (:value)
1 A single record (:record)
2 A map from id to record (:table)
3 A map from id to array of duplicate records (:table)
The dimension defines class and structures of GraphData objects
Class Method Summary collapse
- .field_class(dimension) ⇒ Object
- .kind(dimension) ⇒ Object
- .valid?(dimension, min: 0) ⇒ Boolean
- .validate(dim, min: 0, unwind: 1) ⇒ Object
- .value_class(dimension) ⇒ Object
Class Method Details
.field_class(dimension) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/pg_graph/data/dimension.rb', line 24 def self.field_class(dimension) validate(dimension) case dimension when 0; Column when 1; RecordField when 2; TableField when 3; MmTableField end end |
.kind(dimension) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/pg_graph/data/dimension.rb', line 16 def self.kind(dimension) case dimension when 0; :value when 1; :record when 2, 3; :table end end |
.valid?(dimension, min: 0) ⇒ Boolean
12 13 14 |
# File 'lib/pg_graph/data/dimension.rb', line 12 def self.valid?(dimension, min: 0) dimension.is_a?(Integer) && (min..3).include?(dimension) end |
.validate(dim, min: 0, unwind: 1) ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/pg_graph/data/dimension.rb', line 43 def self.validate(dim, min: 0, unwind: 1) constrain dim, Integer, unwind: unwind constrain dim, lambda { |d| Dimension.valid?(d, min: min) }, "Out of range value: #{dim}", unwind: unwind end |
.value_class(dimension) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/pg_graph/data/dimension.rb', line 34 def self.value_class(dimension) validate(dimension, min: 1) case dimension when 1; RecordValue when 2; TableValue when 3; MmTableValue end end |