Top Level Namespace
Defined Under Namespace
Modules: Factbook
Instance Method Summary collapse
- #convert_cia(cia) ⇒ Object
-
#webget ⇒ Object
more 3rd party gems/libs require ‘props’.
Instance Method Details
#convert_cia(cia) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/factbook-readers/convert.rb', line 3 def convert_cia( cia ) ## convert from "raw" on-the-wire cia format to ## "standard" compact "classic" format data = {} cia['categories'].each do |cia_cat| cat = data[ cia_cat['title'] ] = {} cia_cat['fields'].each do |cia_field| field = cat[ cia_field['name'] ] = {} if cia_field['subfields'] cia_field['subfields'].each do |cia_subfield| subfield = field[ cia_subfield['name'] ] = {} subfield[ 'text' ] = cia_subfield['content'] end puts "== #{cia_cat['title']} / #{cia_field['name']} - skipping field content (w/ subfields):" puts " >#{cia_field['content']}<" puts " ?? same as:" cia_field['subfields'].each do |cia_subfield| puts " #{cia_subfield['name']}: >#{cia_subfield['content']}<" end else field[ 'text' ] = cia_field['content'] end if cia_field[ 'field_note' ] field[ 'note' ] = cia_field[ 'field_note' ] end end end data end |
#webget ⇒ Object
more 3rd party gems/libs require ‘props’
5 |
# File 'lib/factbook-readers.rb', line 5 require 'webget' |