module BELParser::Language::Specification
Specification
defines the common behavior of any language specification. It includes the syntactic and semantic rules of the language.
Constants
- EMPTY_ARRAY
Attributes
causal_relationships[R]
correlative_relationships[R]
decreasing_relationships[R]
deprecated_relationships[R]
direct_relationships[R]
directed_relationships[R]
genomic_relationships[R]
increasing_relationships[R]
indirect_relationships[R]
listable_relationships[R]
self_relationships[R]
Public Instance Methods
freeze_categories()
click to toggle source
# File lib/bel_parser/language/specification.rb, line 122 def freeze_categories instance_variables.each do |ivar| next unless ivar.to_s =~ /@[a-zA-Z0-9]+_relationships/ instance_variable_set(ivar, instance_variable_get(ivar).freeze) end end
function(short_or_long_form)
click to toggle source
# File lib/bel_parser/language/specification.rb, line 16 def function(short_or_long_form) @indexed_functions[short_or_long_form] end
functions(*short_or_long_form)
click to toggle source
# File lib/bel_parser/language/specification.rb, line 32 def functions(*short_or_long_form) if short_or_long_form.empty? @functions.freeze else @indexed_functions.values_at(*short_or_long_form) end end
inspect()
click to toggle source
# File lib/bel_parser/language/specification.rb, line 72 def inspect "BEL specification, version #@version" end
relationship(short_or_long_form)
click to toggle source
# File lib/bel_parser/language/specification.rb, line 20 def relationship(short_or_long_form) @indexed_relationships[short_or_long_form] end
relationships(*short_or_long_form)
click to toggle source
# File lib/bel_parser/language/specification.rb, line 40 def relationships(*short_or_long_form) if short_or_long_form.empty? @relationships.freeze else @indexed_relationships.values_at(*short_or_long_form) end end
return_type(return_type)
click to toggle source
# File lib/bel_parser/language/specification.rb, line 24 def return_type(return_type) @indexed_return_types[return_type] end
return_types(*return_types)
click to toggle source
# File lib/bel_parser/language/specification.rb, line 64 def return_types(*return_types) if return_types.empty? @return_types.freeze else @indexed_return_types.values_at(*return_types) end end
upgrades()
click to toggle source
# File lib/bel_parser/language/specification.rb, line 48 def upgrades @upgrades.freeze end
uri()
click to toggle source
# File lib/bel_parser/language/specification.rb, line 8 def uri @uri end
value_encoding(value_encoding)
click to toggle source
# File lib/bel_parser/language/specification.rb, line 28 def value_encoding(value_encoding) @indexed_value_encodings[value_encoding] end
version()
click to toggle source
# File lib/bel_parser/language/specification.rb, line 12 def version @version end
Protected Instance Methods
assign_relationship_categories(relationships)
click to toggle source
# File lib/bel_parser/language/specification.rb, line 98 def assign_relationship_categories(relationships) relationships.each do |rel| rel.methods(false).grep(/(.*?)\?/) do |method_name| if rel.method(method_name).call category = method_name.to_s.delete('?') add_relationship_to_category(rel, category) end end end freeze_categories nil end
index_long_short(language_objects)
click to toggle source
@param [Array<#long,#short>] language_objects to be indexed by long
and short
method return
# File lib/bel_parser/language/specification.rb, line 78 def index_long_short(language_objects) Hash[ language_objects.flat_map do |obj| [[obj.short, obj], [obj.long, obj]] end ] end
index_sym(language_objects)
click to toggle source
@param [Array<#to_sym>] language_objects to be indexed by to_sym
method return
# File lib/bel_parser/language/specification.rb, line 89 def index_sym(language_objects) Hash[ language_objects.map do |obj| [obj.to_sym, obj] end ] end
Private Instance Methods
add_relationship_to_category(relationship, category)
click to toggle source
# File lib/bel_parser/language/specification.rb, line 113 def add_relationship_to_category(relationship, category) category_ivar = "@#{category}_relationships".to_sym unless instance_variable_defined? category_ivar instance_variable_set(category_ivar, []) end instance_variable_get(category_ivar) << relationship end