The format data helper is a small and simple group of two helpers that matches a piece of data with it’s default and formats the output depending on whether or not it matches.
<td align='center'><%= format_data {'color' => 'red', 'size_inc' => 0, 'data' => obj.diffs, 'default' => 0} %></td>
Would produce the data wrapped in the specified formatting
<font color = 'red' size=+0>DATA</font>
if the ‘data’ field differed from the value of the ‘default’ field, else the data field is returned without surrounding formatting.
<td align='center'><%= format_matching_data( {'color' => 'red', 'size_inc' => 0, 'data' => obj.diffs, 'default' => 0} ) %></td>
Would produce that same formatting if the ‘data’ field matched the ‘default’ field.
The ‘color’ field defaults to ‘red’
The ‘size_inc’ field defaults to 0
the ‘data’ field must be provided
the ‘default’ field defaults to 0
Thus, the above call to the helper could be written as
<td align='center'><%= format_matching_data 'data' => obj.diffs %></td>
Simply add the folowing you your helper file
def format_data (hash) hash['color' ] ? color = hash['color' ] : color = 'red' hash['size_inc'] ? size_inc = hash['size_inc'] : size_inc = 0 hash['default' ] ? def_val = hash['default' ] : def_val = 0 hash['def_out' ] ? def_out = hash['def_out' ] : def_out = def_val data = hash['data'] fontfilled = "<font color = \'#{color}\' size=\+#{size_inc}>#{data}</font>" return def_out if data.to_s == def_val.to_s return fontfilled end def format_matching_data (hash) hash['color' ] ? color = hash['color' ] : color = 'red' hash['size_inc'] ? size_inc = hash['size_inc'] : size_inc = 0 hash['default' ] ? def_val = hash['default' ] : def_val = 0 hash['def_out' ] ? def_out = hash['def_out' ] : def_out = def_val data = hash['data'] fontfilled = "<font color = \'#{color}\' size=\+#{size_inc}>#{data}</font>" return fontfilled if data.to_s == def_val.to_s return def_out end
The format data helper is a small and simple group of two helpers that matches a piece of data with it’s default and formats the output depending on whether or not it matches.
<td align='center'><%= format_data {'color' => 'red', 'size_inc' => 0, 'data' => obj.diffs, 'default' => 0} %></td>
Would produce the data wrapped in the specified formatting
<font color = 'red' size=+0>DATA</font>
if the ‘data’ field differed from the value of the ‘default’ field, else the data field is returned without surrounding formatting.
<td align='center'><%= format_matching_data( {'color' => 'red', 'size_inc' => 0, 'data' => obj.diffs, 'default' => 0} ) %></td>
Would produce that same formatting if the ‘data’ field matched the ‘default’ field.
The ‘color’ field defaults to ‘red’
The ‘size_inc’ field defaults to 0
the ‘data’ field must be provided
the ‘default’ field defaults to 0
Thus, the above call to the helper could be written as
<td align='center'><%= format_matching_data 'data' => obj.diffs %></td>
Simply add the folowing you your helper file
def format_data (hash) hash['color' ] ? color = hash['color' ] : color = 'red' hash['size_inc'] ? size_inc = hash['size_inc'] : size_inc = 0 hash['default' ] ? def_val = hash['default' ] : def_val = 0 hash['def_out' ] ? def_out = hash['def_out' ] : def_out = def_val data = hash['data'] fontfilled = "<font color = \'#{color}\' size=\+#{size_inc}>#{data}</font>" return def_out if data.to_s == def_val.to_s return fontfilled end def format_matching_data (hash) hash['color' ] ? color = hash['color' ] : color = 'red' hash['size_inc'] ? size_inc = hash['size_inc'] : size_inc = 0 hash['default' ] ? def_val = hash['default' ] : def_val = 0 hash['def_out' ] ? def_out = hash['def_out' ] : def_out = def_val data = hash['data'] fontfilled = "<font color = \'#{color}\' size=\+#{size_inc}>#{data}</font>" return fontfilled if data.to_s == def_val.to_s return def_out end