Module: ERLE::Registry
- Defined in:
- lib/erle/registry.rb
Class Attribute Summary collapse
-
._enclosures ⇒ Object
Returns the value of attribute _enclosures.
-
._patterns ⇒ Object
Returns the value of attribute _patterns.
Class Method Summary collapse
- .enclosure(klass, one, two) ⇒ Object
- .open_find(str) ⇒ Object
- .openings ⇒ Object
- .openings_regex ⇒ Object
- .openings_source ⇒ Object
- .pattern(klass, pat) ⇒ Object
- .pattern_find ⇒ Object
- .sorted_encolsures ⇒ Object
Class Attribute Details
._enclosures ⇒ Object
Returns the value of attribute _enclosures.
5 6 7 |
# File 'lib/erle/registry.rb', line 5 def _enclosures @_enclosures end |
._patterns ⇒ Object
Returns the value of attribute _patterns.
6 7 8 |
# File 'lib/erle/registry.rb', line 6 def _patterns @_patterns end |
Class Method Details
.enclosure(klass, one, two) ⇒ Object
12 13 14 |
# File 'lib/erle/registry.rb', line 12 def self.enclosure(klass, one, two) @_enclosures[one] = klass end |
.open_find(str) ⇒ Object
31 32 33 34 35 |
# File 'lib/erle/registry.rb', line 31 def self.open_find(str) sorted_encolsures.find do |k, v| str =~ k end end |
.openings ⇒ Object
41 42 43 |
# File 'lib/erle/registry.rb', line 41 def self.openings @openings ||= sorted_encolsures.keys end |
.openings_regex ⇒ Object
49 50 51 |
# File 'lib/erle/registry.rb', line 49 def self.openings_regex @openings_regex ||= Regexp.new("(#{openings_source.join('|')})") end |
.openings_source ⇒ Object
45 46 47 |
# File 'lib/erle/registry.rb', line 45 def self.openings_source @openings_source ||= openings.map(&:source) end |
.pattern(klass, pat) ⇒ Object
16 17 18 |
# File 'lib/erle/registry.rb', line 16 def self.pattern(klass, pat) (@_patterns[klass] ||= Set.new).add(pat) end |
.pattern_find ⇒ Object
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/erle/registry.rb', line 20 def self.pattern_find return unless block_given? @_patterns.each do |klass, patterns| pattern = patterns.find do |pattern| yield(pattern) end return [klass, pattern] if pattern end nil end |
.sorted_encolsures ⇒ Object
37 38 39 |
# File 'lib/erle/registry.rb', line 37 def self.sorted_encolsures @sorted_encolsures ||= @_enclosures.sort_by { |pattern, klass| pattern.source.length }.reverse.to_h end |