Class: ODDB::Util::Multilingual
- Inherits:
-
Object
- Object
- ODDB::Util::Multilingual
- Includes:
- OddbUri, M10lMethods
- Defined in:
- lib/oddb/export/yaml.rb,
lib/oddb/util/multilingual.rb,
lib/oddb/persistence/og/util/multilingual.rb
Constant Summary
Constants included from OddbUri
Instance Attribute Summary
Attributes included from M10lMethods
Instance Method Summary collapse
- #add_synonym(synonym) ⇒ Object
- #all ⇒ Object
-
#initialize(canonical = {}) ⇒ Multilingual
constructor
A new instance of Multilingual.
- #merge(other) ⇒ Object
Methods included from M10lMethods
#<=>, #==, #empty?, #method_missing, #to_s
Methods included from OddbUri
#to_yaml, #to_yaml_map, #to_yaml_type
Constructor Details
#initialize(canonical = {}) ⇒ Multilingual
Returns a new instance of Multilingual.
51 52 53 54 |
# File 'lib/oddb/util/multilingual.rb', line 51 def initialize(canonical={}) super @synonyms = [] end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ODDB::Util::M10lMethods
Instance Method Details
#add_synonym(synonym) ⇒ Object
55 56 57 |
# File 'lib/oddb/util/multilingual.rb', line 55 def add_synonym(synonym) @synonyms.push(synonym).uniq! && synonym end |
#all ⇒ Object
58 59 60 61 62 |
# File 'lib/oddb/util/multilingual.rb', line 58 def all terms = super.concat(@synonyms) terms.concat(terms.collect do |term| term.gsub(/[^\w]/, '') end) terms.uniq end |
#merge(other) ⇒ Object
63 64 65 |
# File 'lib/oddb/util/multilingual.rb', line 63 def merge(other) @synonyms.concat(other.all).uniq! end |