Skip to content

Commit

Permalink
refactoring: stand-in class methods against of meta-code
Browse files Browse the repository at this point in the history
  • Loading branch information
Mifrill committed Sep 18, 2018
1 parent 3ed05e1 commit 221c264
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/roo/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -115,13 +115,12 @@ def collect_last_row_col_for_sheet(sheet)
{ first_row: first_row, first_column: first_column, last_row: last_row, last_column: last_column }
end

%w(first_row last_row first_column last_column).each do |key|
class_eval <<-EOS, __FILE__, __LINE__ + 1
def #{key}(sheet = default_sheet) # def first_row(sheet = default_sheet)
read_cells(sheet) # read_cells(sheet)
@#{key}[sheet] ||= first_last_row_col_for_sheet(sheet)[:#{key}] # @first_row[sheet] ||= first_last_row_col_for_sheet(sheet)[:first_row]
end # end
EOS
%i(first_row last_row first_column last_column).each do |key|
ivar = "@#{key}".to_sym
define_method(key) do |sheet = default_sheet|
read_cells(sheet)
instance_variable_get(ivar)[sheet] ||= first_last_row_col_for_sheet(sheet)[key]
end
end

def inspect
Expand Down

0 comments on commit 221c264

Please sign in to comment.