Skip to content

Commit

Permalink
Remove warnings "assigned but unused variable"
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Jan 15, 2013
1 parent 5936354 commit 23b555c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
18 changes: 8 additions & 10 deletions lib/spreadsheet/excel/reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def read_bof
# 6 2 Build year
# 8 4 File history flags
# 12 4 Lowest Excel version that can read all records in this file
pos, @bof, len, work = get_next_chunk
_, @bof, _, work = get_next_chunk
## version and datatype are common to all Excel-Versions. Later versions
# have additional information such as build-id and -year (from BIFF5).
# These are ignored for the time being.
Expand Down Expand Up @@ -178,7 +178,7 @@ def read_boundsheet work, pos, len
# 6 var. Sheet name: BIFF5/BIFF7: Byte string,
# 8-bit string length (➜ 3.3)
# BIFF8: Unicode string, 8-bit string length (➜ 3.4)
offset, visibility, type = work.unpack("VC2")
offset, _, _ = work.unpack("VC2")
name = client read_string(work[6..-1]), @workbook.encoding
if @boundsheets
@boundsheets[0] += 1
Expand Down Expand Up @@ -442,15 +442,14 @@ def read_hlink worksheet, work, pos, len
# [var.] 2∙tl (optional, see option flags) Character array of the text
# mark without “#” sign, no Unicode string header, always
# 16-bit characters, zero-terminated
firstrow, lastrow, firstcol, lastcol, guid, opts = work.unpack 'v4H32x4V'
firstrow, lastrow, firstcol, lastcol, _, opts = work.unpack 'v4H32x4V'
has_link = opts & 0x0001
absolute = opts & 0x0002
desc = opts & 0x0014
textmark = opts & 0x0008
target = opts & 0x0080
unc = opts & 0x0100
link = Link.new
url, description = nil
_, description = nil
pos = 32
if desc > 0
description, pos = read_hlink_string work, pos
Expand Down Expand Up @@ -610,7 +609,7 @@ def read_mulblank worksheet, addr, work
# 4 2∙nc List of nc=lc-fc+1 16-bit indexes to XF records (➜ 6.115)
# 4+2∙nc 2 Index to last column (lc)
row, column, *xfs = work.unpack 'v*'
last_column = xfs.pop # unused
xfs.pop #=> last_column
xfs.each_with_index do |xf, idx| set_cell worksheet, row, column + idx, xf end
end
def read_mulrk worksheet, addr, work
Expand Down Expand Up @@ -655,7 +654,7 @@ def read_row worksheet, addr
@pos = addr[:offset]
found = false
while tuple = get_next_chunk
pos, op, len, work = tuple
pos, op, _, work = tuple
case op
when :eof # ● EOF ➜ 6.36 - we should only get here if there is just
# one Row-Block
Expand Down Expand Up @@ -783,7 +782,6 @@ def read_merged_cells worksheet, work, pos, len
end

def read_workbook
worksheet = nil
previous_op = nil
while tuple = get_next_chunk
pos, op, len, work = tuple
Expand Down Expand Up @@ -1029,7 +1027,7 @@ def read_xf work, pos, len
# 13-7 0x3f80 Colour index (➜ 6.70)
# for pattern background
fmt = Format.new
font_idx, numfmt, xf_type, xf_align, xf_rotation, xf_indent, xf_used_attr,
font_idx, numfmt, _, xf_align, xf_rotation, xf_indent, _,
xf_borders, xf_brdcolors, xf_pattern = work.unpack binfmt(:xf)
fmt.number_format = @formats[numfmt]
## this appears to be undocumented: the first 4 fonts seem to be accessed
Expand Down Expand Up @@ -1084,7 +1082,7 @@ def set_missing_row_address worksheet, work, pos, len
# Offset Size Contents
# 0 2 Index of this row
# 2 2 Index to this column
row_index, column_index = work.unpack 'v2'
row_index, _ = work.unpack 'v2'
unless worksheet.offsets[row_index]
@current_row_block_offset ||= [pos]
data = {
Expand Down
4 changes: 2 additions & 2 deletions lib/spreadsheet/excel/writer/workbook.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def write_changes workbook, io
reader.seek lastpos = 0
workbook.offsets.select do |key, pair|
workbook.changes.include? key
end.sort_by do |key, (pos, len)|
end.sort_by do |key, (pos, _)|
pos
end.each do |key, (pos, len)|
data = reader.read(pos - lastpos)
Expand Down Expand Up @@ -538,7 +538,7 @@ def write_string_part writer, op, data, wide
## if we're writing wide characters, we need to make sure we don't cut
# characters in half
if wide > 0 && data.size > @recordsize_limit
remove = @recordsize_limit - data.size
remove = @recordsize_limit - bef
remove -= remove % 2
rest = data.slice!(remove..-1)
write_op writer, op, data
Expand Down
3 changes: 1 addition & 2 deletions lib/spreadsheet/excel/writer/worksheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def write_changes reader, endpos, sst_status
and minimal code that generates this warning. Thanks!
EOS
end
work = work.sort_by do |key, (pos, len)|
work = work.sort_by do |key, (pos, _)|
[pos, key.is_a?(Integer) ? key : -1]
end
work.each do |key, (pos, len)|
Expand Down Expand Up @@ -598,7 +598,6 @@ def write_hlink row, col, link
def write_hyperlink_table
# TODO: theoretically it's possible to write fewer records by combining
# identical neighboring links in cell-ranges
links = []
@worksheet.each do |row|
row.each_with_index do |cell, idx|
if cell.is_a? Link
Expand Down

0 comments on commit 23b555c

Please sign in to comment.