Class: Unitsml::Unitsdb::Prefixes

Inherits:
Unitsdb::Prefixes
  • Object
show all
Includes:
Finders
Defined in:
lib/unitsml/unitsdb/prefixes.rb

Instance Method Summary collapse

Methods included from Finders

#find_first_in, #find_first_through

Instance Method Details

#ascii_symbolsObject



17
18
19
20
21
22
23
24
# File 'lib/unitsml/unitsdb/prefixes.rb', line 17

def ascii_symbols
  prefixes.each_with_object([]) do |prefix, names_array|
    symbol = prefix.symbols.map(&:ascii)
    next if symbol.empty?

    names_array.concat(symbol)
  end
end

#find_by_id(p_id) ⇒ Object



8
9
10
# File 'lib/unitsml/unitsdb/prefixes.rb', line 8

def find_by_id(p_id)
  find_first_through(prefixes, via: :identifiers, field: :id, value: p_id)
end

#find_by_symbol_name(ascii_sym) ⇒ Object



12
13
14
15
# File 'lib/unitsml/unitsdb/prefixes.rb', line 12

def find_by_symbol_name(ascii_sym)
  find_first_through(prefixes, via: :symbols, field: :ascii,
                               value: ascii_sym)
end