Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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
Add Comment
Please, Sign In to add comment