Class: Syntaxer::LanguageRules

Inherits:
Array
  • Object
show all
Defined in:
lib/syntaxer/language_definition.rb

Instance Method Summary collapse

Instance Method Details

#<<(smth) ⇒ Object



26
27
28
29
# File 'lib/syntaxer/language_definition.rb', line 26

def << (smth)
  raise LanguageDefinitionException.new "can't be other then LanguageDefinition class object" unless smth.is_a?(LanguageDefinition)
  super        
end

#find(name) ⇒ Object



40
41
42
# File 'lib/syntaxer/language_definition.rb', line 40

def find(name)
  self.detect{|ld| ld.name == name}
end

#find_or_create(name) ⇒ Object



31
32
33
34
35
36
37
38
# File 'lib/syntaxer/language_definition.rb', line 31

def find_or_create(name)
  found = find(name) 
  unless found
    found = LanguageDefinition.new(name)
    self << found
  end
  found
end