Class: Regin::Options

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Options

Returns a new instance of Options.



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rack/mount/vendor/regin/regin/options.rb', line 13

def initialize(*args)
  if args.first.is_a?(Hash)
    @multiline  = args[0][:multiline]
    @ignorecase = args[0][:ignorecase]
    @extended   = args[0][:extended]
  else
    @multiline  = args[0]
    @ignorecase = args[1]
    @extended   = args[2]
  end
end

Instance Attribute Details

#extendedObject (readonly)

Returns the value of attribute extended.



11
12
13
# File 'lib/rack/mount/vendor/regin/regin/options.rb', line 11

def extended
  @extended
end

#ignorecaseObject (readonly)

Returns the value of attribute ignorecase.



11
12
13
# File 'lib/rack/mount/vendor/regin/regin/options.rb', line 11

def ignorecase
  @ignorecase
end

#multilineObject (readonly)

Returns the value of attribute multiline.



11
12
13
# File 'lib/rack/mount/vendor/regin/regin/options.rb', line 11

def multiline
  @multiline
end

Class Method Details

.from_int(flags) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/rack/mount/vendor/regin/regin/options.rb', line 3

def self.from_int(flags)
  multiline  = flags & Regexp::MULTILINE != 0
  ignorecase = flags & Regexp::IGNORECASE != 0
  extended   = flags & Regexp::EXTENDED != 0

  new(multiline, ignorecase, extended)
end

Instance Method Details

#any?(explicit = false) ⇒ Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
# File 'lib/rack/mount/vendor/regin/regin/options.rb', line 25

def any?(explicit = false)
  if explicit
    !multiline.nil? || !ignorecase.nil? || !extended.nil?
  else
    multiline || ignorecase || extended
  end
end

#to_h(explicit = false) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/rack/mount/vendor/regin/regin/options.rb', line 33

def to_h(explicit = false)
  if explicit
    options = {}
    options[:multiline]  = multiline  unless multiline.nil?
    options[:ignorecase] = ignorecase unless ignorecase.nil?
    options[:extended]   = extended   unless extended.nil?
    options
  else
    { :multiline => multiline,
      :ignorecase => ignorecase,
      :extended => extended }
  end
end

#to_iObject



47
48
49
50
51
52
53
# File 'lib/rack/mount/vendor/regin/regin/options.rb', line 47

def to_i
  flag = 0
  flag |= Regexp::MULTILINE if multiline
  flag |= Regexp::IGNORECASE if ignorecase
  flag |= Regexp::EXTENDED if extended
  flag
end