Class: General::GSpecial
- Defined in:
- lib/gpartials/gspecial.rb
Overview
Created: 7 - 29 - 2016
Constant Summary collapse
- REGEX =
Regular expression that matches special partials
/\A@(?<key>\w+)\;/
- SPECIALS =
Special character information
{ at: "@", pd: "#", lt: "<", gt: ">", op: "(", cp: ")", ob: "[", cb: "]", oc: "{", cc: "}", ms: "-", ps: "+", st: "*", pc: "%", bs: "\\", fs: "/", dl: "$" }
- REGEXES =
Special regex information
{ at: /@/, pd: /#/, lt: /\</, gt: /\>/, op: /\(/, cp: /\)/, ob: /\[/, cb: /\]/, oc: /\{/, cc: /\}/, ms: /\-/, ps: /\+/, st: /\*/, pc: /\%/, bs: /\\/, fs: /\//, dl: /\$/ }
Constants inherited from GText
Instance Attribute Summary
Attributes inherited from GPartial
Instance Method Summary collapse
-
#initialize(match, defaults = {}) ⇒ GSpecial
constructor
Initializes the GSpecial with the given match.
-
#regex(first = true) ⇒ Object
Returns the GSpecial as a regex.
-
#string(first = true) ⇒ Object
Returns the string representation of the GSpecial.
Methods inherited from GText
Constructor Details
#initialize(match, defaults = {}) ⇒ GSpecial
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
62 63 64 65 |
# File 'lib/gpartials/gspecial.rb', line 62 def initialize(match, defaults={}) super SPECIALS[match[:key].to_sym], {} @key = match[:key].to_sym end |
Instance Method Details
#regex(first = true) ⇒ Object
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
79 |
# File 'lib/gpartials/gspecial.rb', line 79 def regex(first=true); REGEXES[@key]; end |
#string(first = true) ⇒ Object
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
72 |
# File 'lib/gpartials/gspecial.rb', line 72 def string(first=true); "@#{@key.to_s};"; end |