Class: Glark::MatchSpec

Inherits:
Object
  • Object
show all
Defined in:
lib/glark/match/spec.rb

Direct Known Subclasses

MatchOptions

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(colors) ⇒ MatchSpec

Returns a new instance of MatchSpec.



20
21
22
23
24
25
26
27
28
# File 'lib/glark/match/spec.rb', line 20

def initialize colors
  @colors = colors
  @expr = nil
  @extended = false
  @extract_matches = false
  @ignorecase = false
  @whole_lines = false
  @whole_words = false
end

Instance Attribute Details

#exprObject

the expression to be evaluated



13
14
15
# File 'lib/glark/match/spec.rb', line 13

def expr
  @expr
end

#extendedObject

whether to use extended regular expressions



14
15
16
# File 'lib/glark/match/spec.rb', line 14

def extended
  @extended
end

#extract_matchesObject

Returns the value of attribute extract_matches.



15
16
17
# File 'lib/glark/match/spec.rb', line 15

def extract_matches
  @extract_matches
end

#ignorecaseObject

match case



16
17
18
# File 'lib/glark/match/spec.rb', line 16

def ignorecase
  @ignorecase
end

#whole_linesObject

true means patterns must match the entire line



17
18
19
# File 'lib/glark/match/spec.rb', line 17

def whole_lines
  @whole_lines
end

#whole_wordsObject

true means all patterns are ‘b’ed front and back



18
19
20
# File 'lib/glark/match/spec.rb', line 18

def whole_words
  @whole_words
end

Instance Method Details

#create_expression_factoryObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/glark/match/spec.rb', line 30

def create_expression_factory
  exprargs = Hash.new
  exprargs[:extended] = @extended
  exprargs[:extract_matches] = @extract_matches
  exprargs[:ignorecase] = @ignorecase
  exprargs[:text_colors] = text_colors
  exprargs[:whole_lines] = @whole_lines
  exprargs[:whole_words] = @whole_words
  
  ExpressionFactory.new exprargs
end

#read_expression(args, warn_option = false) ⇒ Object



42
43
44
# File 'lib/glark/match/spec.rb', line 42

def read_expression args, warn_option = false
  @expr = create_expression_factory.make_expression args, warn_option
end

#set_text_color(index, text_color) ⇒ Object



54
55
56
# File 'lib/glark/match/spec.rb', line 54

def set_text_color index, text_color
  @colors.text_colors[index] = text_color
end

#set_text_colors(text_colors) ⇒ Object



50
51
52
# File 'lib/glark/match/spec.rb', line 50

def set_text_colors text_colors
  @colors.text_colors = text_colors
end

#text_colorsObject



46
47
48
# File 'lib/glark/match/spec.rb', line 46

def text_colors
  @colors.text_colors
end