Class: Unitsml::Unitsdb::Dimension
- Inherits:
-
Unitsdb::Dimension
- Object
- Unitsdb::Dimension
- Unitsml::Unitsdb::Dimension
- Defined in:
- lib/unitsml/unitsdb/dimension.rb
Constant Summary collapse
- QUANTITY_KEYS =
%i[ length mass time thermodynamic_temperature amount_of_substance luminous_intensity plane_angle electric_current ].freeze
Instance Attribute Summary collapse
-
#parsable ⇒ Object
readonly
Returns the value of attribute parsable.
-
#parsables ⇒ Object
readonly
Returns the value of attribute parsables.
-
#processed_keys ⇒ Object
readonly
Returns the value of attribute processed_keys.
-
#vector ⇒ Object
readonly
Returns the value of attribute vector.
Instance Method Summary collapse
- #dim_symbols ⇒ Object
- #id ⇒ Object
-
#initialize(attrs) ⇒ Dimension
constructor
A new instance of Dimension.
- #processed_symbol ⇒ Object
- #set_vector ⇒ Object
Constructor Details
#initialize(attrs) ⇒ Dimension
Returns a new instance of Dimension.
22 23 24 25 26 27 28 |
# File 'lib/unitsml/unitsdb/dimension.rb', line 22 def initialize(attrs) @quantities = {} @parsables = {} @processed_keys = [] @parsable = false super end |
Instance Attribute Details
#parsable ⇒ Object (readonly)
Returns the value of attribute parsable.
17 18 19 |
# File 'lib/unitsml/unitsdb/dimension.rb', line 17 def parsable @parsable end |
#parsables ⇒ Object (readonly)
Returns the value of attribute parsables.
17 18 19 |
# File 'lib/unitsml/unitsdb/dimension.rb', line 17 def parsables @parsables end |
#processed_keys ⇒ Object (readonly)
Returns the value of attribute processed_keys.
17 18 19 |
# File 'lib/unitsml/unitsdb/dimension.rb', line 17 def processed_keys @processed_keys end |
#vector ⇒ Object (readonly)
Returns the value of attribute vector.
17 18 19 |
# File 'lib/unitsml/unitsdb/dimension.rb', line 17 def vector @vector end |
Instance Method Details
#dim_symbols ⇒ Object
40 41 42 43 44 |
# File 'lib/unitsml/unitsdb/dimension.rb', line 40 def dim_symbols processed_keys.flat_map do |vec| dimension_symbols_for(public_send(vec)).map(&:id) end.compact end |
#id ⇒ Object
56 57 58 |
# File 'lib/unitsml/unitsdb/dimension.rb', line 56 def id identifiers.find { |id| id.type == "nist" }&.id end |
#processed_symbol ⇒ Object
46 47 48 |
# File 'lib/unitsml/unitsdb/dimension.rb', line 46 def processed_symbol public_send(processed_keys.first).symbol end |
#set_vector ⇒ Object
50 51 52 53 54 |
# File 'lib/unitsml/unitsdb/dimension.rb', line 50 def set_vector @set_vector ||= Utility::DIMS_VECTOR.map do |h| public_send(Utility.underscore(h))&.power end.join(":") end |