Class: Regexp

Inherits:
Object
  • Object
show all
Defined in:
lib/core_ext/regexp.rb

Defined Under Namespace

Classes: Template

Instance Method Summary collapse

Instance Method Details

#append(other_regex) ⇒ Object



4
5
6
7
8
9
10
11
# File 'lib/core_ext/regexp.rb', line 4

def append(other_regex)
  if(other_regex.is_a? Regexp)
    other_string = other_regex.source
  else
    other_string = other_regex.to_s
  end
  Regexp.new(self.source+other_string)
end

#prepend(other_regex) ⇒ Object



12
13
14
15
16
17
18
19
# File 'lib/core_ext/regexp.rb', line 12

def prepend(other_regex)
  if(other_regex.is_a? Regexp)
    other_string = other_regex.source
  else
    other_string = other_regex.to_s
  end
  Regexp.new(other_string+self.source)
end

#templateObject



20
21
22
23
24
25
# File 'lib/core_ext/regexp.rb', line 20

def template
  if(!@template)
    @template = Regexp::Template.new(source:self.source)
  end
  return @template
end