Module: WLang::RuleSet::Encoding

Defined in:
lib/wlang/rulesets/encoding_ruleset.rb

Overview

Encoding RuleSet, commonly installed in any wlang dialect. Note that this ruleset overrides ${...} implemented in WLang::RuleSet::Basic.

For an overview of this ruleset, see the wlang specification file.

Constant Summary

DEFAULT_RULESET =

Default mapping between tag symbols and methods

{'&' => :main_encoding, '&;' => :entities_encoding, 
"&'" => :single_quoting, '&"' => :double_quoting,
"$" => :injection, "'" => :single_quoted, 
'"' => :double_quoted}

Class Method Summary (collapse)

Class Method Details

+ (Object) double_quoted(parser, offset)

Double-quoted as "{wlang/ruby}



63
64
65
66
67
68
# File 'lib/wlang/rulesets/encoding_ruleset.rb', line 63

def self.double_quoted(parser, offset)
  expression, reached = parser.parse(offset, "wlang/hosted")
  result = parser.evaluate(expression)
  encoded = parser.encode(result.to_s, "double-quoting")
  ['"' << encoded, reached]
end

+ (Object) double_quoting(parser, offset)

Double-quoting as &"{...}



40
41
42
43
44
# File 'lib/wlang/rulesets/encoding_ruleset.rb', line 40

def self.double_quoting(parser, offset)
  parsed, reached = parser.parse(offset)
  result = parser.encode(parsed, "double-quoting")
  [result, reached]
end

+ (Object) entities_encoding(parser, offset)

Entities-encoding as &;{...}



26
27
28
29
30
# File 'lib/wlang/rulesets/encoding_ruleset.rb', line 26

def self.entities_encoding(parser, offset)
  parsed, reached = parser.parse(offset)
  result = parser.encode(parsed, "entities-encoding")
  [result, reached]
end

+ (Object) injection(parser, offset)

Injection as ${wlang/ruby}



47
48
49
50
51
52
# File 'lib/wlang/rulesets/encoding_ruleset.rb', line 47

def self.injection(parser, offset)
  expression, reached = parser.parse(offset, "wlang/hosted")
  result = parser.evaluate(expression)
  encoded = parser.encode(result.to_s, "main-encoding")
  [encoded, reached]
end

+ (Object) main_encoding(parser, offset)

Main encoding as &{...}



19
20
21
22
23
# File 'lib/wlang/rulesets/encoding_ruleset.rb', line 19

def self.main_encoding(parser, offset)
  parsed, reached = parser.parse(offset)
  result = parser.encode(parsed, "main-encoding")
  [result, reached]
end

+ (Object) single_quoted(parser, offset)

Single-quoted as '{wlang/ruby}



55
56
57
58
59
60
# File 'lib/wlang/rulesets/encoding_ruleset.rb', line 55

def self.single_quoted(parser, offset)
  expression, reached = parser.parse(offset, "wlang/hosted")
  result = parser.evaluate(expression)
  encoded = parser.encode(result.to_s, "single-quoting")
  ["'" << encoded, reached]
end

+ (Object) single_quoting(parser, offset)

Single-quoting as &'{...}



33
34
35
36
37
# File 'lib/wlang/rulesets/encoding_ruleset.rb', line 33

def self.single_quoting(parser, offset)
  parsed, reached = parser.parse(offset)
  result = parser.encode(parsed, "single-quoting")
  [result, reached]
end