module SY::PREFIX_TABLE

Public Class Methods

all_prefixes() click to toggle source

List of full prefixes and short prefixes.

# File lib/sy/fixed_assets_of_the_module.rb, line 79
def all_prefixes
  @all ||= full_prefixes + prefix_abbreviations
end
full_prefixes() click to toggle source

List of full prefixes.

# File lib/sy/fixed_assets_of_the_module.rb, line 66
def full_prefixes
  @full ||= map { |row| row[:full] }
end
parse_sps(sps, unit_symbols) click to toggle source

Parses an SPS using a list of permitted unit symbols, currying it with own all_prefixes.

# File lib/sy/fixed_assets_of_the_module.rb, line 86
def parse_sps sps, unit_symbols
  SY::SPS_PARSER.( sps, unit_symbols, all_prefixes )
end
prefix_abbreviations() click to toggle source

List of prefix abbreviations.

# File lib/sy/fixed_assets_of_the_module.rb, line 72
def prefix_abbreviations
  @short ||= map { |row| row[:short] }
end
Also aliased as: short_prefixes
row(clue) click to toggle source

A hash of clue => corresponding_row pairs.

# File lib/sy/fixed_assets_of_the_module.rb, line 92
def row clue
  ( @rowꜧ ||= Hash.new do |, key|
      case key
      when Symbol then
        rslt = [key.to_s]
        [key] = rslt if rslt
      else
        r = find { |r|
          r[:full] == key || r[:short] == key || r[:factor] == key
        }
        [key] = r if r
      end
    end )[ clue ]
end
short_prefixes()
to_factor(clue) click to toggle source

Converts a clue to a factor.

# File lib/sy/fixed_assets_of_the_module.rb, line 128
def to_factor clue
  ( @factorꜧ ||= Hash.new do |, key|
      result = row( key )[:factor]
      [key] = result if result
    end )[ clue ]
end
to_full(clue) click to toggle source

Converts a clue to a full prefix.

# File lib/sy/fixed_assets_of_the_module.rb, line 109
def to_full clue
  ( @fullꜧ ||= Hash.new do |, key|
      result = row( key )
      result = result[:full]
      [key] = result if result
    end )[ clue ]
end
to_short(clue) click to toggle source

Converts a clue to a prefix abbreviation.

# File lib/sy/fixed_assets_of_the_module.rb, line 119
def to_short clue
  ( @shortꜧ ||= Hash.new do |, key|
      result = row( key )[:short]
      [key] = result if result
    end )[ clue ]
end