Method: FormatEngine::SpecInfo#parse
- Defined in:
- lib/format_engine/spec_info.rb
#parse(target) ⇒ Object
Parse the source string for a target string or regex or return nil.
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/format_engine/spec_info.rb', line 47 def parse(target) #Handle the width option if specified. if (width = fmt.width) > 0 head, tail = src[0...width], src[width..-1] || "" else head, tail = src, "" end #Do the parse on the input string or regex. @prematch, @match, @postmatch = head.partition(target) #Analyze the results. if found? @src = @postmatch + tail @match else nil end end |