Class: Regex::MatchOption
- Inherits:
-
MonadicExpression
- Object
- Expression
- CompoundExpression
- MonadicExpression
- Regex::MatchOption
- Defined in:
- lib/regex/match_option.rb
Overview
Represents a set of options that influences the way a regular (sub)expression can perform its matching.
Instance Attribute Summary collapse
-
#flags ⇒ Array
readonly
Array of Regexp flags.
Attributes inherited from MonadicExpression
Attributes inherited from Expression
Instance Method Summary collapse
-
#==(other) ⇒ Object
Equality operator.
-
#combine_opts ⇒ Object
Combine all options/flags into one integer value that is compliant as second argument of with Regexp#new method.
-
#initialize(theChild, theFlags) ⇒ MatchOption
constructor
Constructor.
Methods inherited from MonadicExpression
Methods inherited from CompoundExpression
Methods inherited from Expression
Constructor Details
#initialize(theChild, theFlags) ⇒ MatchOption
Constructor.
15 16 17 18 |
# File 'lib/regex/match_option.rb', line 15 def initialize(theChild, theFlags) super(theChild) @flags = theFlags end |
Instance Attribute Details
#flags ⇒ Array (readonly)
Returns Array of Regexp flags.
10 11 12 |
# File 'lib/regex/match_option.rb', line 10 def flags @flags end |
Instance Method Details
#==(other) ⇒ Object
Equality operator
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/regex/match_option.rb', line 32 def ==(other) return true if object_id == other.object_id if other.kind_of?(MatchOption) isEqual = ((flags == other.flags) && (child == other.child)) else isEqual = false end return isEqual end |
#combine_opts ⇒ Object
Combine all options/flags into one integer value that is compliant as second argument of with Regexp#new method. return [Integer]
23 24 25 26 27 28 |
# File 'lib/regex/match_option.rb', line 23 def combine_opts result = 0 flags.each { |f| result |= f } return result end |