class PMLCode::Content::Parser
Constants
- HL_END
- HL_START
- PART_END
- PART_START
Public Class Methods
new(raw)
click to toggle source
# File lib/pmlcode/content.rb, line 57 def initialize(raw) @raw = raw end
Public Instance Methods
result()
click to toggle source
# File lib/pmlcode/content.rb, line 61 def result @result ||= run end
Private Instance Methods
lines()
click to toggle source
# File lib/pmlcode/content.rb, line 92 def lines @raw.split(/\r?\n/) end
process(text)
click to toggle source
# File lib/pmlcode/content.rb, line 73 def process(text) case text when PART_START @parts << $1 nil when PART_END @parts.reject! { |part| part == $1 } nil when HL_START @highlighted = true nil when HL_END @highlighted = false nil else Line.new(text, @parts.dup, @highlighted) end end
run()
click to toggle source
# File lib/pmlcode/content.rb, line 67 def run @parts = [] @highlighted = nil lines.map(&method(:process)).compact end