Class: Typedown::Shorthand

Inherits:
Object
  • Object
show all
Defined in:
lib/typedown/shorthand.rb

Class Method Summary collapse

Class Method Details

.process(body) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/typedown/shorthand.rb', line 5

def self.process body
  # Find all occurences mathcing the shorthand syntax
  # 'action/param1[/param2]
  offset = 0
  while(match = body[offset..-1].match(/\'\w+[\/\w+]+/)) do
    m = match[0]
    res = self.resolve m
    body.gsub!(m, res) if res
    offset += match.begin(0) + (res || m).length
  end
  body
end