Created
December 19, 2017 23:21
final version
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
comma = "" | |
last_index = doc.xpath('//*[not(*)][text()]').size.pred | |
puts doc.xpath('//*[not(*)][text()]').map.with_index{ |n,i| | |
if i == last_index | |
comma = "" | |
else | |
comma = "," | |
end | |
if is_number?(n.text) | |
"'#{n.parent.name}.#{n.name}': #{n.text}" + comma | |
else | |
"'#{n.parent.name}.#{n.name}': '#{n.text}'" + comma | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment