class General::GSpecial

Represents a special character in a GTemplate

Author: Anshul Kharbanda Created: 7 - 29 - 2016

Constants

REGEX

Regular expression that matches special partials

REGEXES

Special regex information

SPECIALS

Special character information

Public Class Methods

new(match, defaults={}) click to toggle source

Initializes the GSpecial with the given match

Parameter: match - the match object of the GSpecial Parameter: defaults - the hash of default data from the GTemplate

Calls superclass method
# File lib/gpartials/gspecial.rb, line 62
def initialize(match, defaults={})
        super SPECIALS[match[:key].to_sym], {}
        @key = match[:key].to_sym
end

Public Instance Methods

regex(first=true) click to toggle source

Returns the GSpecial as a regex

Parameter: first - true if this partial is the first of it's kind in a GTemplate

Returns: the GSpecial as a regex

# File lib/gpartials/gspecial.rb, line 79
def regex(first=true); REGEXES[@key]; end
string(first=true) click to toggle source

Returns the string representation of the GSpecial

Parameter: first - true if this partial is the first of it's kind in a GTemplate

Returns: the string representation of the GSpecial

# File lib/gpartials/gspecial.rb, line 72
def string(first=true); "@#{@key.to_s};"; end