Module: ApplicationHelper

Included in:
MifFile::Helper
Defined in:
app/helpers/application_helper.rb

Overview

Methods added to this helper will be available to all templates in the application.

Instance Method Summary collapse

Instance Method Details

#document_type(file_name, ens = '') ⇒ Object


20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/helpers/application_helper.rb', line 20

def document_type file_name, ens=''
  mif_file = MifFile.find_by_path(file_name)

  case mif_file.file_type
    when 'Clauses'
      if ens == 'interleaved'
        "clauses_interleaved"
      elsif ens == 'interleaved_wide'
        "clauses_interleaved_wide"
      else
        "clauses"
      end
    when 'Schedules'
      "schedules"
    when 'Arrangement'
      "arrangement"
    when 'Amendments'
      "amendment_paper"
    when 'Tabled Amendments'
      "tabled_amendments"
    when 'Marshalled List'
      "marshalled_list"
    when 'Report'
      "report"
    when 'Tabled Report'
      "report"
    else
      if file_name =~ /Finance_Clauses.xml$/
        "clauses"
      else
        "converted"
      end
  end
end

#external_sheetObject


12
13
14
# File 'app/helpers/application_helper.rb', line 12

def external_sheet
  params[:style]
end

4
5
6
7
8
9
10
# File 'app/helpers/application_helper.rb', line 4

def link_to_url value
  if value
    link_to_if(value[/http/], h(value).sub('http://',''), value)
  else
    ''
  end
end

#stylesheet_path(file_name, ens = '') ⇒ Object


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'app/helpers/application_helper.rb', line 55

def stylesheet_path file_name, ens=''
  mif_file = MifFile.find_by_path(file_name)

  case mif_file.file_type
    when 'Clauses'
      if ens == 'interleaved'
        "clauses/clauses_interleaved"
      elsif ens == 'interleaved_wide'
        "clauses/clauses_interleaved_wide"
      elsif ens == 'interleaved_inline'
        "clauses/clauses_interleaved_inline"
      else
        "clauses/clauses"
      end
    when 'Schedules'
      if ens == 'interleaved'
        "schedules/schedules_interleaved"
      elsif ens == 'interleaved_wide'
        "schedules/schedules_interleaved_wide"
      elsif ens == 'interleaved_inline'
        "schedules/schedules_interleaved_inline"
      else
        "schedules/schedules"
      end
    when 'Arrangement'
      "arrangement/arrangement"
    when 'Amendments'
      "amendment_paper/amendment_paper"
    when 'Tabled Amendments'
      "amendment_paper/tabled_amendments"
    when 'Marshalled List'
      "amendment_paper/marshalled_list"
    when 'Report'
      "report/report"
    when 'Tabled Report'
      "report/report"
    else
      if file_name =~ /Finance_Clauses.xml$/
        "clauses/clauses"
      else
        "converted"
      end
  end
end

#target_fileObject


16
17
18
# File 'app/helpers/application_helper.rb', line 16

def target_file
  params[:file] || "Index"
end