Class: Acronym
- Inherits:
-
Object
- Object
- Acronym
- Defined in:
- lib/wcdma_bb/acronym.rb
Overview
Collect, hold, and look up all acronyms
Constant Summary collapse
- @@acronyms =
a hash containing all acronyms: string => array of strings
Hash.new
Class Method Summary collapse
-
.add(acronym, fullname) ⇒ nil
Store acronym => fullname pair.
-
.clear ⇒ nil
Clear all saved acronyms.
-
.search_acronym(pattern) ⇒ Hash
Look up for one acronym pattern.
Class Method Details
.add(acronym, fullname) ⇒ nil
Store acronym => fullname pair
13 14 15 16 17 18 19 |
# File 'lib/wcdma_bb/acronym.rb', line 13 def self.add(acronym, fullname) values = @@acronyms.fetch(acronym, Array.new) if not values.include?(fullname) values << fullname @@acronyms[acronym] = values end end |
.clear ⇒ nil
Clear all saved acronyms
37 38 39 |
# File 'lib/wcdma_bb/acronym.rb', line 37 def self.clear() @@acronyms = Hash.new end |
.search_acronym(pattern) ⇒ Hash
Look up for one acronym pattern
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/wcdma_bb/acronym.rb', line 24 def self.search_acronym(pattern) result = Hash.new pattern = Regexp.new(pattern) @@acronyms.each { |key, value| if pattern.match(key) result[key] = value end } return result end |