Created
March 25, 2012 03:50
-
-
Save drKreso/2191257 to your computer and use it in GitHub Desktop.
Usage
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 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' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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)