Class: Regin::Options
- Inherits:
-
Object
- Object
- Regin::Options
- Defined in:
- lib/rack/mount/vendor/regin/regin/options.rb
Instance Attribute Summary collapse
-
#extended ⇒ Object
readonly
Returns the value of attribute extended.
-
#ignorecase ⇒ Object
readonly
Returns the value of attribute ignorecase.
-
#multiline ⇒ Object
readonly
Returns the value of attribute multiline.
Class Method Summary collapse
Instance Method Summary collapse
- #any?(explicit = false) ⇒ Boolean
-
#initialize(*args) ⇒ Options
constructor
A new instance of Options.
- #to_h(explicit = false) ⇒ Object
- #to_i ⇒ Object
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
#extended ⇒ Object (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 |
#ignorecase ⇒ Object (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 |
#multiline ⇒ Object (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
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 = {} [:multiline] = multiline unless multiline.nil? [:ignorecase] = ignorecase unless ignorecase.nil? [:extended] = extended unless extended.nil? else { :multiline => multiline, :ignorecase => ignorecase, :extended => extended } end end |
#to_i ⇒ Object
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 |