Class: Livetext::ParseGeneral
Instance Attribute Summary
Attributes inherited from StringParser
#eos, #i, #len, #line
Class Method Summary
collapse
Instance Method Summary
collapse
#eos?, #grab, #lookahead, #peek, #prev, #remainder, #skip_spaces, #ungrab
Constructor Details
9
10
11
|
# File 'lib/livetext/parser/general.rb', line 9
def initialize(str)
super
end
|
Class Method Details
.parse_vars(lines, prefix: nil) ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/livetext/parser/general.rb', line 21
def self.parse_vars(lines, prefix: nil)
lines.map! {|line| line.sub(/# .*/, "").strip }
pairs = []
lines.each do |line|
next if line.strip.empty?
var, value = line.split(" ", 2)
var = prefix + "." + var if prefix
pairs << [var, value]
end
pairs
end
|
Instance Method Details
#strip_quotes ⇒ Object
13
14
15
16
17
18
19
|
# File 'lib/livetext/parser/general.rb', line 13
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
|