module Lite::Measurements::Helpers::ConversionHelper
Private Instance Methods
all_keys()
click to toggle source
# File lib/lite/measurements/helpers/conversion_helper.rb, line 10 def all_keys [imperical_keys, metric_keys].flatten end
convert_to_imperical_units(units, convert_to:, convert_from:, from: nil, to: nil)
click to toggle source
rubocop:disable Layout/LineLength
# File lib/lite/measurements/helpers/conversion_helper.rb, line 15 def convert_to_imperical_units(units, convert_to:, convert_from:, from: nil, to: nil) units = shift_units(units, type: klass::METRIC_UNITS, from: from, to: convert_to) shift_units(units / klass::CONVERTER, type: klass::IMPERICAL_UNITS, from: convert_from, to: to) end
convert_to_imperical_units?(from, to)
click to toggle source
rubocop:enable Layout/LineLength
# File lib/lite/measurements/helpers/conversion_helper.rb, line 26 def convert_to_imperical_units?(from, to) metric_keys.include?(from) && imperical_keys.include?(to) end
convert_to_metric_units(units, convert_to:, convert_from:, from: nil, to: nil)
click to toggle source
# File lib/lite/measurements/helpers/conversion_helper.rb, line 20 def convert_to_metric_units(units, convert_to:, convert_from:, from: nil, to: nil) units = shift_units(units, type: klass::IMPERICAL_UNITS, from: from, to: convert_to) shift_units(units * klass::CONVERTER, type: klass::METRIC_UNITS, from: convert_from, to: to) end
convert_to_metric_units?(from, to)
click to toggle source
# File lib/lite/measurements/helpers/conversion_helper.rb, line 30 def convert_to_metric_units?(from, to) imperical_keys.include?(from) && metric_keys.include?(to) end
imperical_keys()
click to toggle source
# File lib/lite/measurements/helpers/conversion_helper.rb, line 38 def imperical_keys @imperical_keys ||= klass::IMPERICAL_UNITS.keys end
klass()
click to toggle source
# File lib/lite/measurements/helpers/conversion_helper.rb, line 34 def klass self.class end
metric_keys()
click to toggle source
# File lib/lite/measurements/helpers/conversion_helper.rb, line 42 def metric_keys @metric_keys ||= klass::METRIC_UNITS.keys end
shift_between_imperical_units?(from, to)
click to toggle source
# File lib/lite/measurements/helpers/conversion_helper.rb, line 46 def shift_between_imperical_units?(from, to) imperical_keys.include?(from) && imperical_keys.include?(to) end
shift_between_metric_units?(from, to)
click to toggle source
# File lib/lite/measurements/helpers/conversion_helper.rb, line 50 def shift_between_metric_units?(from, to) metric_keys.include?(from) && metric_keys.include?(to) end