Module: WLang::RuleSet::PlainText

Defined in:
lib/wlang/dialects/plain_text_dialect.rb

Overview

Defines rulset of the plain-text dialect

Constant Summary

DEFAULT_RULESET =

Default mapping between tag symbols and methods

{'+' => :upcase, '-' => :downcase}

Class Method Summary collapse

Class Method Details

.downcase(parser, offset) ⇒ Object

Downcase rule as -{wlang/hosted}



58
59
60
61
62
63
64
# File 'lib/wlang/dialects/plain_text_dialect.rb', line 58

def self.downcase(parser, offset)
  expression, reached = parser.parse(offset, "wlang/hosted")
  value = parser.evaluate(expression)
  value = value.nil? ? "" : value.to_s
  result = EncoderSet::PlainText.downcase(value)
  [result, reached]
end

.upcase(parser, offset) ⇒ Object

Upcase rule as +{wlang/hosted}



49
50
51
52
53
54
55
# File 'lib/wlang/dialects/plain_text_dialect.rb', line 49

def self.upcase(parser, offset)
  expression, reached = parser.parse(offset, "wlang/hosted")
  value = parser.evaluate(expression)
  value = value.nil? ? "" : value.to_s
  result = WLang::EncoderSet::PlainText.upcase(value)
  [result, reached]
end