Class: Canon::Comparison::Dimensions::DimensionSet
- Inherits:
-
Object
- Object
- Canon::Comparison::Dimensions::DimensionSet
- Defined in:
- lib/canon/comparison/dimensions/dimension_set.rb
Overview
Immutable collection of dimensions for a specific format.
Each format (XML, JSON, YAML) has its own DimensionSet listing the comparison aspects relevant to that format. Provides lookup by name, enumeration, and existence checks.
Instance Attribute Summary collapse
-
#format ⇒ Object
readonly
Returns the value of attribute format.
Instance Method Summary collapse
-
#[](name) ⇒ Dimension?
Lookup a dimension by name.
-
#dimension?(name) ⇒ Boolean
Whether this format has a dimension with the given name.
-
#initialize(format, dimensions) ⇒ DimensionSet
constructor
A new instance of DimensionSet.
-
#names ⇒ Array<Symbol>
All dimension names for this format, in definition order.
Constructor Details
#initialize(format, dimensions) ⇒ DimensionSet
Returns a new instance of DimensionSet.
16 17 18 19 20 21 22 |
# File 'lib/canon/comparison/dimensions/dimension_set.rb', line 16 def initialize(format, dimensions) @format = format @dimensions = dimensions.to_h do |dim| [dim.name, dim] end.freeze freeze end |
Instance Attribute Details
#format ⇒ Object (readonly)
Returns the value of attribute format.
12 13 14 |
# File 'lib/canon/comparison/dimensions/dimension_set.rb', line 12 def format @format end |
Instance Method Details
#[](name) ⇒ Dimension?
Lookup a dimension by name.
28 29 30 |
# File 'lib/canon/comparison/dimensions/dimension_set.rb', line 28 def [](name) @dimensions[name] end |
#dimension?(name) ⇒ Boolean
Whether this format has a dimension with the given name.
43 44 45 |
# File 'lib/canon/comparison/dimensions/dimension_set.rb', line 43 def dimension?(name) @dimensions.key?(name) end |
#names ⇒ Array<Symbol>
All dimension names for this format, in definition order.
35 36 37 |
# File 'lib/canon/comparison/dimensions/dimension_set.rb', line 35 def names @dimensions.keys end |