Class: Regin::Alternation

Inherits:
Collection show all
Defined in:
lib/rack/mount/vendor/regin/regin/alternation.rb

Instance Method Summary collapse

Methods inherited from Collection

#+, #==, #[], #each, #eql?, #first, #include?, #last, #length, #match, #to_regexp

Constructor Details

#initialize(*args) ⇒ Alternation

Returns a new instance of Alternation.



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/rack/mount/vendor/regin/regin/alternation.rb', line 3

def initialize(*args)
  args, options = extract_options(args)

  if args.length == 1 && args.first.instance_of?(Array)
    super(args.first)
  else
    super(args)
  end

  if options.key?(:ignorecase)
    @array.map! { |e| e.dup(:ignorecase => options[:ignorecase]) }
  end
end

Instance Method Details

#dup(options = {}) ⇒ Object



28
29
30
# File 'lib/rack/mount/vendor/regin/regin/alternation.rb', line 28

def dup(options = {})
  self.class.new(to_a, options)
end

#flagsObject



24
25
26
# File 'lib/rack/mount/vendor/regin/regin/alternation.rb', line 24

def flags
  0
end

#inspectObject

:nodoc:



36
37
38
# File 'lib/rack/mount/vendor/regin/regin/alternation.rb', line 36

def inspect #:nodoc:
  to_s.inspect
end

#literal?Boolean

Returns true if expression could be treated as a literal string.

Alternation groups are never literal.

Returns:

  • (Boolean)


20
21
22
# File 'lib/rack/mount/vendor/regin/regin/alternation.rb', line 20

def literal?
  false
end

#to_s(parent = false) ⇒ Object



32
33
34
# File 'lib/rack/mount/vendor/regin/regin/alternation.rb', line 32

def to_s(parent = false)
  map { |e| e.to_s(parent) }.join('|')
end