Class: RegexpExamples::DotGroup

Inherits:
Object
  • Object
show all
Includes:
RandomResultBySample
Defined in:
lib/regexp-examples/groups.rb

Overview

A special case of CharGroup, for the pattern /./ (For example, we never need to care about ignorecase here!)

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from RandomResultBySample

#random_result

Methods included from ForceLazyEnumerators

#force_if_lazy

Constructor Details

#initialize(multiline) ⇒ DotGroup

Returns a new instance of DotGroup.



113
114
115
# File 'lib/regexp-examples/groups.rb', line 113

def initialize(multiline)
  @multiline = multiline
end

Instance Attribute Details

#multilineObject (readonly)

Returns the value of attribute multiline.



112
113
114
# File 'lib/regexp-examples/groups.rb', line 112

def multiline
  @multiline
end

Instance Method Details

#resultObject



117
118
119
120
121
122
# File 'lib/regexp-examples/groups.rb', line 117

def result
  chars = multiline ? CharSets::Any : CharSets::AnyNoNewLine
  chars.lazy.map do |result|
    GroupResult.new(result)
  end
end