Sha256: 97fb41c9d970c01cb9505f35d69ffddacc0bb56a0a80ebde390f3eea02038dfd

Contents?: true

Size: 891 Bytes

Versions: 12

Compression:

Stored size: 891 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

12 entries across 12 versions & 1 rubygems

Version Path
livetext-0.9.42 lib/livetext/parser/general.rb
livetext-0.9.41 lib/livetext/parser/general.rb
livetext-0.9.40 lib/livetext/parser/general.rb
livetext-0.9.39 lib/livetext/parser/general.rb
livetext-0.9.38 lib/livetext/parser/general.rb
livetext-0.9.37 lib/livetext/parser/general.rb
livetext-0.9.36 lib/livetext/parser/general.rb
livetext-0.9.35 lib/livetext/parser/general.rb
livetext-0.9.33 lib/livetext/parser/general.rb
livetext-0.9.32 lib/livetext/parser/general.rb
livetext-0.9.31 lib/livetext/parser/general.rb
livetext-0.9.30 lib/livetext/parser/general.rb