Module: Wptemplates::Utils
- Included in:
- Parser
- Defined in:
- lib/wptemplates/utils.rb
Class Method Summary collapse
- .fixpoint(options = {}) ⇒ Object
- .normalize_link(string, anchor = false) ⇒ Object
- .normalize_linklabel(string) ⇒ Object
- .symbolize(string) ⇒ Object
Class Method Details
.fixpoint(options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 |
# File 'lib/wptemplates/utils.rb', line 27 def fixpoint = {} clone = [:clone] || false cur = [:start] begin pre = clone && !cur.nil? ? cur.clone : cur cur = yield(cur) end while cur != pre cur end |
.normalize_link(string, anchor = false) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/wptemplates/utils.rb', line 5 def normalize_link string, anchor = false normalized = string.clone normalized.tr!('_',' ') normalized.strip! normalized.squeeze!(' ') normalized[0] = normalized[0,1].upcase unless anchor normalized end |
.normalize_linklabel(string) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/wptemplates/utils.rb', line 14 def normalize_linklabel string normalized = string.clone normalized.strip! normalized.squeeze!(' ') normalized end |
.symbolize(string) ⇒ Object
21 22 23 24 25 |
# File 'lib/wptemplates/utils.rb', line 21 def symbolize string symbolized = normalize_link(string) symbolized.tr!(' ','_') symbolized.downcase.to_sym end |