What's new in Kvx 0.4.0?

The Kvx gem now features methods summary() and body() which allow access to the internal Hash objects.

Parsing a raw Kvx document

require 'kvx'

s = "
<?kvx?>
title: My Mobile Phone number
tags: mobile phone number mobilenumber
-----------------------

sim_type: data only
expires: 27-Jul-2015
instructions: unenecrypt using `gg rlo`
mobile_number: 0790HjtUtUJussHjZm
sim_no: 2751FkHjTveJJu50JutU
"

kvx = Kvx.new(s)
kvx.to_h
#=> {:sim_type=>"data only", :expires=>"27-Jul-2015", :ins...

puts kvx.to_xml

Output:

<?xml version='1.0' encoding='UTF-8'?>
<kvx created='2015-04-29 15:53:01 +0100'>
  <summary>
    <title>My Mobile Phone number</title>
    <tags>mobile phone number mobilenumber</tags>
  </summary>
  <body>
    <sim_type>data only</sim_type>
    <expires>27-Jul-2015</expires>
    <instructions>unenecrypt using `gg rlo`</instructions>
    <mobile_number>0790HjtUtUJussHjZm</mobile_number>
    <sim_no>2751FkHjTveJJu50JutU</sim_no>
  </body>
</kvx>

Parsing XML

require 'kvx'

s = &lt;&lt;EOF
&lt;?xml version='1.0' encoding='UTF-8'?&gt;
&lt;kvx created='2015-04-29 15:53:01 +0100'&gt;
  &lt;summary&gt;
    &lt;title&gt;My Mobile Phone number&lt;/title&gt;
    &lt;tags&gt;mobile phone number mobilenumber&lt;/tags&gt;
  &lt;/summary&gt;
  &lt;body&gt;
    &lt;sim_type&gt;data only&lt;/sim_type&gt;
    &lt;expires&gt;27-Jul-2015&lt;/expires&gt;
    &lt;instructions&gt;unenecrypt using `gg rlo`&lt;/instructions&gt;
    &lt;mobile_number&gt;0790HjtUtUJussHjZm&lt;/mobile_number&gt;
    &lt;sim_no&gt;2751FkHjTveJJu50JutU&lt;/sim_no&gt;
  &lt;/body&gt;
&lt;/kvx&gt;
EOF

kvx = Kvx.new(s)
kvx.to_h
#=&gt; {:sim_type=&gt;"data only", :expires=&gt;"27-Jul-2015" ...

kvx.summary
#=&gt; {:title=&gt;"My Mobile Phone number", :tags=&gt;"mobile pho
kvx.body
#=&gt; {:sim_type=&gt;"data only", :expires=&gt;"27-...

Resources