Skip to content

Instantly share code, notes, and snippets.

@darwin
Created November 16, 2008 02:10
Show Gist options
  • Save darwin/25360 to your computer and use it in GitHub Desktop.
Save darwin/25360 to your computer and use it in GitHub Desktop.
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