Module: FsTemplate::TemplateFile::OldWay

Included in:
FsTemplate::TemplateFile
Defined in:
lib/fs_template/template_file.rb

Instance Method Summary collapse

Instance Method Details

#apply_body_to_short(base_body) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/fs_template/template_file.rb', line 60

def apply_body_to_short(base_body)
  note_parts = note.to_s.split(":")
  if note == 'append'
    base_body + body
  elsif note_parts[0] == 'insert'
    raise "bad" unless note_parts[1] == 'line'
    base_lines = base_body.split("\n")
    i = note_parts[2].to_i - 1
    base_lines[0...i].join("\n") + body + base_lines[i..-1].join("\n")
  else
    raise "unknown note #{note}"
  end
end

#split_note_and_body_shortObject



50
51
52
53
54
55
56
57
58
# File 'lib/fs_template/template_file.rb', line 50

def split_note_and_body_short
  if full_body =~ /^FSTMODE:([a-z:0-9]+)\s/m
    note = $1
    rest = full_body.gsub(/^FSTMODE:#{note}/,"")
    {:note => note, :body => rest, :format => :short}
  else
    nil
  end
end