Class: GoogleDrive::Alias::Row

Inherits:
Object
  • Object
show all
Defined in:
lib/google_drive/google_drive.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(row_num, row, header, ws) ⇒ Row

Returns a new instance of Row.



38
39
40
41
42
43
# File 'lib/google_drive/google_drive.rb', line 38

def initialize(row_num, row, header, ws)
  @row_num = row_num
  @row     = row
  @header  = header
  @ws      = ws
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, value = nil) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/google_drive/google_drive.rb', line 45

def method_missing(name,value=nil)
  test = name.to_s.gsub(/=$/,'')

  if @header.include?(test) then
    col_num = @header.find_index(test)
    super unless col_num

    col_num += 1
    if name.match(/=$/) then
      @ws[@row_num,col_num] = value
    else
      return @ws[@row_num,col_num]
    end
  else
    super
  end
end

Instance Attribute Details

#row_numObject (readonly)

Returns the value of attribute row_num.



36
37
38
# File 'lib/google_drive/google_drive.rb', line 36

def row_num
  @row_num
end