Class: Regin::Alternation
- Inherits:
-
Collection
- Object
- Collection
- Regin::Alternation
- Defined in:
- lib/rack/mount/vendor/regin/regin/alternation.rb
Instance Method Summary collapse
- #dup(options = {}) ⇒ Object
- #flags ⇒ Object
-
#initialize(*args) ⇒ Alternation
constructor
A new instance of Alternation.
-
#inspect ⇒ Object
:nodoc:.
-
#literal? ⇒ Boolean
Returns true if expression could be treated as a literal string.
- #to_s(parent = false) ⇒ Object
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, = (args) if args.length == 1 && args.first.instance_of?(Array) super(args.first) else super(args) end if .key?(:ignorecase) @array.map! { |e| e.dup(:ignorecase => [: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( = {}) self.class.new(to_a, ) end |
#flags ⇒ Object
24 25 26 |
# File 'lib/rack/mount/vendor/regin/regin/alternation.rb', line 24 def flags 0 end |
#inspect ⇒ Object
: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.
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 |