class Regin::Collection
Public Class Methods
new(*args)
click to toggle source
# File lib/regin/collection.rb, line 5 def initialize(*args) @array = Array.new(*args) end
Public Instance Methods
+(other)
click to toggle source
# File lib/regin/collection.rb, line 30 def +(other) ary = other.is_a?(self.class) ? other.internal_array : other self.class.new(@array + ary) end
[](i)
click to toggle source
# File lib/regin/collection.rb, line 13 def [](i) @array[i] end
each() { |item| ... }
click to toggle source
# File lib/regin/collection.rb, line 9 def each @array.each{ |item| yield item } end
first()
click to toggle source
# File lib/regin/collection.rb, line 22 def first @array.first end
include?(char)
click to toggle source
# File lib/regin/collection.rb, line 45 def include?(char) any? { |e| e.include?(char) } end
last()
click to toggle source
# File lib/regin/collection.rb, line 26 def last @array.last end
length()
click to toggle source
# File lib/regin/collection.rb, line 17 def length @array.length end
Also aliased as: size
match(char)
click to toggle source
# File lib/regin/collection.rb, line 41 def match(char) to_regexp.match(char) end
to_regexp(anchored = false)
click to toggle source
# File lib/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
Protected Instance Methods
extract_options(args)
click to toggle source
# File lib/regin/collection.rb, line 69 def extract_options(args) if args.last.is_a?(Hash) return args[0..-2], args.last else return args, {} end end