Class: ExplanatoryNote

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/explanatory_note.rb

Direct Known Subclasses

NoteByClause, NoteBySchedule, NoteRangeByClause

Instance Method Summary collapse

Instance Method Details

#html_note_textObject


8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'app/models/explanatory_note.rb', line 8

def html_note_text
  @in_list = false
  tokens = note_text.gsub("\r","").gsub(/\n\s+\n/,"\n\n").split("\n\n")

  html = tokens.collect do |token|
    lines = token.split("\n")
    result = []

    if lines.first[/^\s*Clause (\d+|\d+\ {0,1}:.+)\s*$/]
      result << '<span class="NoteClauseTitle">Clause ' + $1 + '</span>'
      make_paragraph result, lines, adj=1
    elsif lines.size > 1 && lines[1][/^\s*Clause (\d+|\d+\ {0,1}:.+)\s*$/]
      result = result << '<span class="NoteClauseTitle">Clause ' + lines[0] + lines[1] + '</span>'
      make_paragraph result, lines, adj=2
    elsif lines.first[/^\s*Schedule (\d+|\d+:.+)\s*$/]
      result << '<span class="NoteScheduleTitle">Schedule ' + $1 + '</span>'
      make_paragraph result, lines, adj=1
    elsif lines.size > 1 && lines[1][/^\s*Schedule (\d+|\d+:.+)\s*$/]
      result = result << '<span class="NoteScheduleTitle">Schedule ' + lines[0] + lines[1] + '</span>'
      make_paragraph result, lines, adj=2
    else
      make_paragraph result, lines
    end

    result.join(' ')
  end

  html.join('')
end