Class: Medidas::DerivedUnit
Instance Attribute Summary collapse
-
#base_unit ⇒ Object
readonly
Returns the value of attribute base_unit.
-
#factor ⇒ Object
readonly
Returns the value of attribute factor.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name:, plural:, base_unit:, factor:) ⇒ DerivedUnit
constructor
A new instance of DerivedUnit.
Methods inherited from Unit
#*, #base_unit?, #coerce, #inspect, #name_for, registered_units, #to_s
Constructor Details
#initialize(name:, plural:, base_unit:, factor:) ⇒ DerivedUnit
Returns a new instance of DerivedUnit.
10 11 12 13 14 15 |
# File 'lib/medidas/derived_unit.rb', line 10 def initialize(name:, plural:, base_unit:, factor: ) @name = name @plural = plural @base_unit = base_unit @factor = factor end |
Instance Attribute Details
#base_unit ⇒ Object (readonly)
Returns the value of attribute base_unit.
3 4 5 |
# File 'lib/medidas/derived_unit.rb', line 3 def base_unit @base_unit end |
#factor ⇒ Object (readonly)
Returns the value of attribute factor.
4 5 6 |
# File 'lib/medidas/derived_unit.rb', line 4 def factor @factor end |
Class Method Details
.[](name, plural: "#{name}s", base_unit:, factor: 1) ⇒ Object
6 7 8 |
# File 'lib/medidas/derived_unit.rb', line 6 def self.[](name, plural: "#{name}s", base_unit:, factor: 1) registered_units[name] ||= new(name: name, plural: plural, base_unit: base_unit, factor: factor) end |