Class: Gergich::Capture::BaseCapture

Inherits:
Object
  • Object
show all
Defined in:
lib/gergich/capture.rb

Class Method Summary collapse

Class Method Details

.inherited(subclass) ⇒ Object



9
10
11
12
13
# File 'lib/gergich/capture.rb', line 9

def self.inherited(subclass)
  super
  name = normalize_captor_class_name(subclass)
  Capture.captors[name] = subclass
end

.normalize_captor_class_name(subclass) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/gergich/capture.rb', line 15

def self.normalize_captor_class_name(subclass)
  name = subclass.name.dup
  # borrowed from AS underscore, since we may not have it
  name.gsub!(/.*::|Capture\z/, "")
  name.gsub!(/([A-Z\d]+)([A-Z][a-z])/, "\\1_\\2")
  name.gsub!(/([a-z\d])([A-Z])/, "\\1_\\2")
  name.tr!("-", "_")
  name.downcase!
end