Skip to content

Instantly share code, notes, and snippets.

@drKreso
Created March 25, 2012 03:50
Show Gist options
  • Save drKreso/2191257 to your computer and use it in GitHub Desktop.
Save drKreso/2191257 to your computer and use it in GitHub Desktop.
Usage
class MaterialConsumption
include MultidimensionalTable
dimensions :year => [:year_1994, :year_1995],
:city => [:buenos_aires],
:material => [:coal, :potassium]
table_data do
year_1994 do
buenos_aires do
coal '8t'
potassium '5t'
end
end
year_1995 do
buenos_aires do
coal '8t'
potassium '6t'
end
end
end
end
mt = new MaterialConsumption
mt.update_attributes(:year => :year_1994, :city => :buenos_aires, :material => :coal)
mt.table_result #=> '8t'
@drKreso
Copy link
Author

drKreso commented Mar 25, 2012

This is usage. Kinda like Ruby DSL to describe multidimensional table. I got it to work but in the process I had trouble with keeping the current context for the rules. So I reimplemented stack (that's how it feels)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment