Created
November 16, 2008 02:10
-
-
Save darwin/25360 to your computer and use it in GitHub Desktop.
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
require "rubygems" | |
require "json" | |
tohle_je_json_z_fajlu = <<HEREDOC | |
{ | |
"disp": "nejaky text", | |
"platforma": [ | |
{ | |
"ido": 1, | |
"jmeno": "prvni", | |
"priorita": 3, | |
"mountpoints": [1,3,4] | |
},{ | |
"ido": 1, | |
"jmeno": "druha", | |
"priorita": 3, | |
"mountpoints": [1,3,4] | |
} | |
] | |
} | |
HEREDOC | |
o = JSON.parse(tohle_je_json_z_fajlu) | |
puts o.inspect | |
module PlatformyMixin | |
def platforma # tento getter by mel byt autogenerovany | |
self['platforma'] | |
end | |
def jmena_platforem | |
platforma.map{|o| o['jmeno'] }.sort! | |
end | |
end | |
o.extend(PlatformyMixin) | |
puts o.jmena_platforem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment