Created
September 26, 2012 22:49
-
-
Save fsrc/3791140 to your computer and use it in GitHub Desktop.
CoffeeScript wrap up values within function objects? Kind of currying?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SimpleSheet | |
# Returns object where each property | |
# represent the index in the array | |
@indices: (columnNames) -> | |
result = {} | |
result[name] = i for i, name of columnNames | |
result | |
constructor: (@gsheet) -> | |
range = @gsheet.getDataRange() | |
table = range.getValues() | |
# Pass table 0th row to indices fn and remove that | |
# row from table array. | |
indices = SimpleSheet.indices table.shift() | |
@rowForIndex = do (table) -> (index) -> | |
table[index] | |
@valueForColumn = do (indices) -> (row, column) -> | |
row[indices[column]] | |
sheet = new SimpleSheet(dataSheet) | |
row = sheet.rowForIndex 3 | |
value = row.valueForColumn 'InvoiceNumber' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment