Class: CodelessCode::Formats::CleanupBody

Inherits:
Object
  • Object
show all
Defined in:
lib/codeless_code/formats/plain.rb

Overview

Tidies up the mixed syntax found in fables

Instance Method Summary collapse

Constructor Details

#initialize(body) ⇒ CleanupBody

Returns a new instance of CleanupBody


39
40
41
# File 'lib/codeless_code/formats/plain.rb', line 39

def initialize(body)
  @body = body
end

Instance Method Details

#to_sObject


43
44
45
46
47
48
49
50
51
# File 'lib/codeless_code/formats/plain.rb', line 43

def to_s
  [
    [%r{//\w*$}, ''],
    [%r{<i>([^<]+)</i>}mi, '\1'],
    [%r{<b>([^<]+)</b>}mi, '\1'],
    [%r{<a[^>]+>([^<]+)</a>}mi, '\1'],
    [%r{/(\w+)/}, '\1']
  ].inject(@body) { |str, args| str.gsub(*args) }
end