Sha256: 4d6f80137f37c69a370203de6afb34bf1678711da6c4bfb07c8ace50b8e973e3
Contents?: true
Size: 889 Bytes
Versions: 5
Compression:
Stored size: 889 Bytes
Contents
make_exception(:MismatchedQuotes, "Error: mismatched quotes") make_exception(:NilValue, "Error: nil value") make_exception(:NullString, "Error: null string") make_exception(:ExpectedString, "Error: expected a string") class Livetext::ParseGeneral < StringParser def initialize(str) super end def strip_quotes raise NullString if @line.empty? start, stop = @line[0], @line[-1] return @line unless %['"].include?(start) raise MismatchedQuotes if start != stop @line[1..-2] end def self.parse_vars(lines, prefix: nil) lines.map! {|line| line.sub(/# .*/, "").strip } # strip comments pairs = [] lines.each do |line| next if line.strip.empty? var, value = line.split(" ", 2) val = Livetext.interpolate(value) var = prefix + "." + var if prefix pairs << [var, value] end pairs end end
Version data entries
5 entries across 5 versions & 1 rubygems