# encoding: utf-8 module LocalPac module ProxyPac class ResultParser class PacResultHtmlStylist attr_reader :class_proxy_port, :class_proxy, :class_proxy_port def initialize(options = {}) @class_request_type = options.fetch(:class_request_type, 'lp_request_type') @class_proxy = options.fetch(:class_proxy, 'lp_proxy') @class_proxy_port = options.fetch(:class_proxy_port, 'lp_proxy_port') end def style_me(result) styled_result = [] styled_result << span(result.request_type, class_request_type) if result.request_type styled_result << " " if result.proxy || result.proxy_port styled_result << span(result.proxy, class_proxy) if result.proxy if result.proxy_port styled_result << ':' styled_result << span(result.proxy_port, class_proxy_port) end result.styled_content = styled_content.join end private def span(content, css_class) "#{content}" end end def parse(string) regex.match(string) result = PacResult.new(string) end private def regex %q{"(?[A-Z]+)\s+(?:(?[0-9]{1,3}(:?\.[0-9]{1,3}){3}):(?[0-9]+))?;?"} end end end end