Sha256: 4d97dbc0d9b421bddff18aacb972dd472c1e93b5b83fd9b68fc5ff9e252ce128
Contents?: true
Size: 947 Bytes
Versions: 2
Compression:
Stored size: 947 Bytes
Contents
require_relative '../livetext' require_relative 'string' 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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
livetext-0.9.22 | lib/parser/general.rb |
livetext-0.9.21 | lib/parser/general.rb |