Class: Regin::Collection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rack/mount/vendor/regin/regin/collection.rb

Direct Known Subclasses

Alternation, Expression

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Collection

Returns a new instance of Collection.



5
6
7
# File 'lib/rack/mount/vendor/regin/regin/collection.rb', line 5

def initialize(*args)
  @array = Array.new(*args)
end

Instance Method Details

#+(other) ⇒ Object



30
31
32
33
# File 'lib/rack/mount/vendor/regin/regin/collection.rb', line 30

def +(other)
  ary = other.is_a?(self.class) ? other.internal_array : other
  self.class.new(@array + ary)
end

#==(other) ⇒ Object

:nodoc:



49
50
51
52
53
54
55
56
57
58
# File 'lib/rack/mount/vendor/regin/regin/collection.rb', line 49

def ==(other) #:nodoc:
  case other
  when String
    other == to_s
  when Array
    other == @array
  else
    eql?(other)
  end
end

#[](i) ⇒ Object



13
14
15
# File 'lib/rack/mount/vendor/regin/regin/collection.rb', line 13

def [](i)
  @array[i]
end

#eachObject



9
10
11
# File 'lib/rack/mount/vendor/regin/regin/collection.rb', line 9

def each
  @array.each{ |item| yield item }
end

#eql?(other) ⇒ Boolean

:nodoc:

Returns:

  • (Boolean)


60
61
62
# File 'lib/rack/mount/vendor/regin/regin/collection.rb', line 60

def eql?(other) #:nodoc:
  other.instance_of?(self.class) && @array.eql?(other.internal_array)
end

#firstObject



22
23
24
# File 'lib/rack/mount/vendor/regin/regin/collection.rb', line 22

def first
  @array.first
end

#include?(char) ⇒ Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/rack/mount/vendor/regin/regin/collection.rb', line 45

def include?(char)
  any? { |e| e.include?(char) }
end

#lastObject



26
27
28
# File 'lib/rack/mount/vendor/regin/regin/collection.rb', line 26

def last
  @array.last
end

#lengthObject Also known as: size



17
18
19
# File 'lib/rack/mount/vendor/regin/regin/collection.rb', line 17

def length
  @array.length
end

#match(char) ⇒ Object



41
42
43
# File 'lib/rack/mount/vendor/regin/regin/collection.rb', line 41

def match(char)
  to_regexp.match(char)
end

#to_regexp(anchored = false) ⇒ Object



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

def to_regexp(anchored = false)
  re = to_s(true)
  re = "\\A#{re}\\Z" if anchored
  Regexp.compile(re, flags)
end