Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify Worksheet#rows to enable returning numeric rows #377

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 21 additions & 1 deletion lib/google_drive/worksheet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,31 @@ def cells
def rows(skip = 0)
nc = num_cols
result = ((1 + skip)..num_rows).map do |row|
(1..nc).map { |col| self[row, col] }.freeze
(1..nc).map do |col|
block_given? ? yield(row, col) : self[row, col]
end.freeze
end
result.freeze
end

# Same as +#rows+, but replacing cells with numeric values where they exist.
# Please note that this will NOT replace dirty cells with their numeric
# value.
#
# @see #rows
# @see #numeric_value
def rows_with_numerics(skip = 0)
rows(skip) { |row, col| numeric_value(row, col) || self[row, col] }
end

# Same as +#rows+, but with input values instead
#
# @see #rows
# @see #input_value
def rows_with_inputs(skip = 0)
rows(skip) { |row, col| input_value(row, col) }
end

# Inserts rows.
#
# e.g.
Expand Down