Class: IssuesHelper::IssueFieldsRows

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TagHelper
Defined in:
app/helpers/issues_helper.rb

Instance Method Summary collapse

Constructor Details

#initializeIssueFieldsRows

Returns a new instance of IssueFieldsRows.


123
124
125
126
# File 'app/helpers/issues_helper.rb', line 123

def initialize
  @left = []
  @right = []
end

Instance Method Details

#cells(label, text, options = {}) ⇒ Object


151
152
153
# File 'app/helpers/issues_helper.rb', line 151

def cells(label, text, options={})
  ('th', "#{label}:", options) + ('td', text, options)
end

#left(*args) ⇒ Object


128
129
130
# File 'app/helpers/issues_helper.rb', line 128

def left(*args)
  args.any? ? @left << cells(*args) : @left
end

#right(*args) ⇒ Object


132
133
134
# File 'app/helpers/issues_helper.rb', line 132

def right(*args)
  args.any? ? @right << cells(*args) : @right
end

#sizeObject


136
137
138
# File 'app/helpers/issues_helper.rb', line 136

def size
  @left.size > @right.size ? @left.size : @right.size
end

#to_htmlObject


140
141
142
143
144
145
146
147
148
149
# File 'app/helpers/issues_helper.rb', line 140

def to_html
  html = ''.html_safe
  blank = ('th', '') + ('td', '')
  size.times do |i|
    left = @left[i] || blank
    right = @right[i] || blank
    html << ('tr', left + right)
  end
  html
end