Class: Richard::Internal::PatternLine

Inherits:
Object
  • Object
show all
Defined in:
lib/richard_iii/internal/text_line.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ PatternLine

Returns a new instance of PatternLine.



18
19
20
# File 'lib/richard_iii/internal/text_line.rb', line 18

def initialize(text)
  @text = text || fail("You need to supply some text even if it's empty")
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



16
17
18
# File 'lib/richard_iii/internal/text_line.rb', line 16

def text
  @text
end

Instance Method Details

#matches?(text) ⇒ Boolean

!

expects lines to start and end with /

Returns:

  • (Boolean)


23
24
25
26
# File 'lib/richard_iii/internal/text_line.rb', line 23

def matches?(text)
  regex = Regexp.new(@text.slice(1,(@text.size-2)))
  false == regex.match(text).nil?
end