(Ruby) Converting string values into assignable properties for OpenStructs...? -
I have found a bit of a strange situation. If I was using a hash, then this problem would be easy, however, I am trying to use "openstrat" in Ruby because it offers some good ways.
Actually, I think I have a return value "" I have a regular expression:
textopts = OpenStruct.new () textopts.recipients = [] Fileparts = fhandle.read.split ("<<->>> FileReport [0] .chomp.each {| L If L = ~ / Reciprint.ACI / I textopets.prashant & lt; & Lt; $ & Amp; Elsif L = ~ / (Server Adress Email Email Address. ***) / i Textopets $ & Amp; = $ And .split (":") [1] end}
me $ & amp; In a valid asset for filling "textopts" I have tried "stability" and some other people but nothing works but I think this is possible, but maybe I'm wrong, obviously, if I was using a hash then I just "textopts [ $ & Amp;;] = ..... ".
Any thoughts?
Keeping the structure of your solution, there is a way to do this:
textopts = OpenStruct.new (: recipient => []) Fileparts = fhandle.read.split ('<->>>) fileparts.first.chomp.each_line do | L Case L, when / Reciprint.EI Textpacks.prashant & lt; & Lt; $ & Amp; When /(Server+Email)Address.*/i textopts.send "# {$ & amp;} =", $ and .split (':') [1] Ended End
But I can not help but I think it should be a proper parser.
Comments
Post a Comment