module MeasureScaler::Prefixes
Constants
- LIST
- MAX_FACTOR
- MIN_FACTOR
- STEP
Public Instance Methods
find_factor(symbol)
click to toggle source
Get the base-10 exponent related to the symbol Example: find_factor
(“M”) # => 6 (million)
# File lib/measure_scaler/prefixes.rb, line 12 def find_factor(symbol) valid?(symbol) ? (LIST.index(symbol)*STEP)+MIN_FACTOR : nil end
find_symbol(factor)
click to toggle source
Get the symbol related to base-10 passed The factor should be a multiple of 3, greater or equal to -24 and smaller or equal to 24 Example: find_symbol
(-3) # => “m” (thousandth)
# File lib/measure_scaler/prefixes.rb, line 20 def find_symbol(factor) return nil if factor%STEP!=0 || factor<MIN_FACTOR || factor>MAX_FACTOR LIST[(factor-MIN_FACTOR)/STEP] end
symbols_list()
click to toggle source
Return the list of available symbols
# File lib/measure_scaler/prefixes.rb, line 31 def symbols_list LIST end
valid?(symbol)
click to toggle source
Is a valid symbol?
# File lib/measure_scaler/prefixes.rb, line 26 def valid?(symbol) LIST.include?(symbol) end