Class: RewriteCond

Inherits:
Object
  • Object
show all
Defined in:
lib/rewrite_cond.rb

Instance Method Summary collapse

Constructor Details

#initialize(line) ⇒ RewriteCond

Returns a new instance of RewriteCond.

Raises:



4
5
6
7
8
9
# File 'lib/rewrite_cond.rb', line 4

def initialize(line)
  @line = line
  self.parse line

  raise InvalidRule.new unless valid?
end

Instance Method Details

#parse(line) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/rewrite_cond.rb', line 11

def parse(line)
  match_data = /RewriteCond[ ]+([^ ]+)[ ]+([^ ]+)([ ]+\[([^ ]+)\]\n?)?$/.match(line)

  return if match_data.nil?

  @expression = match_data[1]
  @compare = match_data[2]
  @flags = match_data[4].nil? ? nil : match_data[4].split(',')
end

#valid?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/rewrite_cond.rb', line 21

def valid?
  !@expression.nil? && !@compare.nil?
end