Re: [External] re: Adding a directory to LOAD_PATH

"Tran, Minh" <[email protected]> Thu, 7 Nov 2019 16:55:07 +0000
Newsgroups gmane.comp.lang.ruby.general
Message-ID <SN6PR05MB53916EF10F581E3A559EB628EE780@SN6PR05MB5391.namprd05.prod.outlook.com>
--===============0329066342==
Content-Language: en-US
Content-Type: multipart/alternative;
	boundary="_000_SN6PR05MB53916EF10F581E3A559EB628EE780SN6PR05MB5391namp_"

--_000_SN6PR05MB53916EF10F581E3A559EB628EE780SN6PR05MB5391namp_
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable


Thank you so much Raj for all of the helps.
Since I am new to Ruby, could I ask on how could I add my project vendor di=
rectory to the load path ?

I did a ruby -e 'puts $LOADPATH' command , and it gave me my current LOAD_P=
ATH

/usr/local/lib/site_ruby/2.3.0
/usr/local/lib/x86_64-linux-gnu/site_ruby
/usr/local/lib/site_ruby
/usr/lib/ruby/vendor_ruby/2.3.0
/usr/lib/x86_64-linux-gnu/ruby/vendor_ruby/2.3.0
/usr/lib/ruby/vendor_ruby
/usr/lib/ruby/2.3.0
/usr/lib/x86_64-linux-gnu/ruby/2.3.0

I am still googling for a Ruby command that I could use to add my vendor fo=
lder to the LOAD_PATH.

Thanks for all of the helps,
Minh


________________________________
From: ruby-talk <[email protected]> on behalf of Raj Sahae <r=
[email protected]>
Sent: Wednesday, November 6, 2019 5:54 PM
To: Ruby users <[email protected]>
Subject: [External] Re: Could not load a Ruby program

This is sort of a strange thing to do. You are using require while dynamica=
lly generating the path based on the location of test.rb, which could chang=
e with respect to your vendor directory.
Your error message would seem to indicate that the relative path of kinetic=
-sdk.rb from test.rb is not what you are specifying.

If you want to use kinetic-sdk.rb as a library file, then the folder you wa=
nt to load it from should be in your load path.
There are a couple ways to do this but in my opinion the easiest to test wi=
th is using "ruby -I"

So if I were you, I would keep kinetic-sdk.rb where it is, and add your pro=
jects vendor directory to the load path, and then call require in test.rb w=
ith that relative path.

test.rb would be something like

#!/usr/bin/ruby
puts "Hello World!"
require 'kinectic-sdk-rb/kinectic-sdk.rb'

And you would run it with a command like

ruby -I my_project/vendor test.rb

You can persist that sort of thing by setting your RUBYLIB env variable, or=
 changing load_path inside your test.rb, etc. There are many ways.


-Raj


On Wed, Nov 6, 2019 at 1:39 PM Tran, Minh <[email protected]<ma=
ilto:[email protected]>> wrote:
Hello,

    I have a scenario that I need to execute a program from the other direc=
tory than my current directory.
I got an error when I ran it, and I would like to seek helps and expertises=
.


My current directory is at my_project, and the program that I would like to=
 execute is at my_project/vendor/kinectic-sdk-rb/kinectic-sdk.rb

In my current directory my_project, I have  a test.rb which contains a very=
 simple line of code such as

#!/usr/bin/ruby
puts "Hello World!"
require File.join (File.expand_path (File.dirname(__FILE__)), 'vendor/kinec=
tic-sdk-rb/kinectic-sdk.rb')


I tried to run the test.rb at my current directory which is my_project , an=
d I got the following error message:

Could not load file kinectic-sdk.rb  from my  /my_project/vendor/kinectic-s=
dk-rb/kinectic-sdk.rb folder.


Thanks for all of your helps,
Minh




________________________________
From: ruby-talk <[email protected]<mailto:ruby-talk-bounces@r=
uby-lang.org>> on behalf of Dan Fitzpatrick <[email protected]<mailto:dan@e=
parklabs.com>>
Sent: Friday, October 25, 2019 12:30 AM
To: [email protected]<mailto:[email protected]> <ruby-talk@ruby=
-lang.org<mailto:[email protected]>>
Subject: [External] Re: How to compare a hash key with a string value

Hello Dun,


First I would change the name of your variable "hash" to something else
because it is not a hash, it is an array of hashes. Since it represents
a list of people, I would call it people.


The main issue is that your keys are getting converted to symbols. So
none of the objects have the "width" attribute as a string.


This is the only thing that continuously annoys me about Ruby:


a =3D
{"label":"Name","value":"Bob","identifier":"field2","type":"oneLineText","p=
age":1,"page_name":"Step
1","width":"100%"}

=3D> {:label=3D>"Name", :value=3D>"Bob", :identifier=3D>"field2",
:type=3D>"oneLineText", :page=3D>1, :page_name=3D>"Step 1", :width=3D>"100%=
"}


b
=3D{"label"=3D>"Name","value"=3D>"Bob","identifier"=3D>"field2","type"=3D>"=
oneLineText","page"=3D>1,"page_name"=3D>"Step
1","width"=3D>"100%"}
=3D> {"label"=3D>"Name", "value"=3D>"Bob", "identifier"=3D>"field2",
"type"=3D>"oneLineText", "page"=3D>1, "page_name"=3D>"Step 1", "width"=3D>"=
100%"}

a['width']

=3D> nil

b['width']

=3D> "100%"

a[:width]

=3D> "100%"


Here is your code working:

people =3D
[{"label":"Name","value":"Bob","identifier":"field2","type":"oneLineText","=
page":1,"page_name":"Step
1","width":"100%"},{"label":"Email","value":"[email protected]<mailto:bob@co=
mpagny.com>","identifier":"field3","type":"email","page":1,"page_name":"Ste=
p
1","width":"100%"},{"label":"Phone
Number","value":"","identifier":"field7","type":"oneLineText","page":1,"pag=
e_name":"Step
1","width":"100%"},{"label":"Comments","value":"some information about
the
compagny","identifier":"field5","type":"textarea","page":1,"page_name":"Ste=
p
1","width":"100%"}]


# If you only need the width attribute, you can do this (no loop on the
attributes needed):

people.each_with_index do |person, i|
   puts "Person is #{i+1}" # First person displays as 1 instead of 0

   puts "The value of width is #{person[:width]}" if person.has_key?(:width=
)
end


# If needed, loop through all the attributes of person (like in your
example), but change to detecting symbol keys

people.each_with_index do |person, i|
   puts "Person is #{i+1}" # First person is 1 instead of 0

   person.each do |key, value|
     if key =3D=3D :width
       puts "The value of width is #{value}"
     end
   end
end


Also, if you are defining your hashes, you don't need to use JSON format
with quoted keys, you can just do:

a =3D {label: "Name", value: "Bob", identifier: "field2", type:
"oneLineText", page: 1, page_name: "Step 1", width: "100%"}


Dan


On 10/24/2019 1:35 AM, Tran, Minh wrote:

Unsubscribe: <mailto:[email protected]?subject=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

________________________________

This e-mail message (including any attachments) is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, distribution
or copying of this message (including any attachments) is strictly
prohibited.

If you have received this message in error, please contact
the sender by reply e-mail message and destroy all copies of the
original message (including attachments).

Unsubscribe: <mailto:[email protected]<mailto:ruby-talk-reque=
[email protected]>?subject=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

--_000_SN6PR05MB53916EF10F581E3A559EB628EE780SN6PR05MB5391namp_
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<html>
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">
<style type=3D"text/css" style=3D"display:none;"> P {margin-top:0;margin-bo=
ttom:0;} </style>
</head>
<body dir=3D"ltr">
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<br>
</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
Thank you so much Raj for all of the helps.</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
Since I am new to Ruby, could I ask on how could I add my project vendor di=
rectory to the load path ?</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<br>
</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
I did a ruby -e 'puts $LOADPATH' command , and it gave me my current LOAD_P=
ATH</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<br>
</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<span>/usr/local/lib/site_ruby/2.3.0<br>
</span>
<div>/usr/local/lib/x86_64-linux-gnu/site_ruby<br>
</div>
<div>/usr/local/lib/site_ruby<br>
</div>
<div>/usr/lib/ruby/vendor_ruby/2.3.0<br>
</div>
<div>/usr/lib/x86_64-linux-gnu/ruby/vendor_ruby/2.3.0<br>
</div>
<div>/usr/lib/ruby/vendor_ruby<br>
</div>
<div>/usr/lib/ruby/2.3.0<br>
</div>
<div>/usr/lib/x86_64-linux-gnu/ruby/2.3.0</div>
<div><br>
</div>
<div>I am still&nbsp;googling for a Ruby command that I could use to add my=
 vendor folder to the LOAD_PATH.</div>
<div><br>
</div>
<div>Thanks for all of the helps,</div>
<div>Minh</div>
<div><br>
</div>
<div><br>
</div>
</div>
<div id=3D"appendonsend"></div>
<hr tabindex=3D"-1" style=3D"width: 98%; display: inline-block;">
<div id=3D"divRplyFwdMsg" dir=3D"ltr"><font color=3D"#000000" face=3D"Calib=
ri, sans-serif" style=3D"font-size: 11pt;"><b>From:</b> ruby-talk &lt;ruby-=
[email protected]&gt; on behalf of Raj Sahae &lt;[email protected]=
m&gt;<br>
<b>Sent:</b> Wednesday, November 6, 2019 5:54 PM<br>
<b>To:</b> Ruby users &lt;[email protected]&gt;<br>
<b>Subject:</b> [External] Re: Could not load a Ruby program</font>
<div>&nbsp;</div>
</div>
<div>
<div dir=3D"ltr">This is sort of a strange thing to do. You are using requi=
re while dynamically generating the path based on the location of test.rb, =
which could change with respect to your vendor directory.
<div>Your error message would seem to indicate that the relative path of ki=
netic-sdk.rb from test.rb is not what you are specifying.</div>
<div><br>
</div>
<div>If you want to use kinetic-sdk.rb as a library file, then the folder y=
ou want to load it from should be in your load path.</div>
<div>There are a couple ways to do this but in my opinion the easiest to te=
st with is using &quot;ruby -I&quot;</div>
<div><br>
</div>
<div>So if I were you, I would keep kinetic-sdk.rb where it is, and add you=
r projects vendor directory to the load path, and then call require in test=
.rb with that relative path.</div>
<div><br>
</div>
<div>test.rb would be something like</div>
<div><font face=3D"arial, sans-serif"><br>
</font></div>
<div>
<div style=3D"color: rgb(0, 0, 0);"><font face=3D"arial, sans-serif"><b>#!/=
usr/bin/ruby<br>
</b></font></div>
<div style=3D"color: rgb(0, 0, 0);"><font face=3D"arial, sans-serif"><b>put=
s &quot;Hello World!&quot;<br>
</b></font></div>
<div style=3D"color: rgb(0, 0, 0);"><font face=3D"arial, sans-serif"><b>req=
uire 'kinectic-sdk-rb/kinectic-sdk.rb'</b></font></div>
<div style=3D"color: rgb(0, 0, 0);"><font face=3D"arial, sans-serif"><b><br=
>
</b></font></div>
<div style=3D"color: rgb(0, 0, 0);"><font face=3D"arial, sans-serif">And yo=
u would run it with a command like</font></div>
<div style=3D"color: rgb(0, 0, 0);"><font face=3D"arial, sans-serif"><br>
</font></div>
<div style=3D"color: rgb(0, 0, 0);"><font face=3D"arial, sans-serif">ruby -=
I&nbsp;</font><span style=3D"color: rgb(34, 34, 34);">my_project/vendor tes=
t.rb</span></div>
<br class=3D"x_gmail-Apple-interchange-newline">
</div>
<div>You can persist that sort of thing by setting your RUBYLIB env variabl=
e, or changing load_path inside your test.rb, etc. There are many ways.</di=
v>
<div><br>
</div>
<div>
<div><br clear=3D"all">
<div>
<div class=3D"x_gmail_signature" dir=3D"ltr">
<div>-Raj</div>
</div>
</div>
<br>
</div>
</div>
</div>
<br>
<div class=3D"x_gmail_quote">
<div class=3D"x_gmail_attr" dir=3D"ltr">On Wed, Nov 6, 2019 at 1:39 PM Tran=
, Minh &lt;<a href=3D"mailto:[email protected]">minh.tran@emory=
healthcare.org</a>&gt; wrote:<br>
</div>
<blockquote class=3D"x_gmail_quote" style=3D"margin: 0px 0px 0px 0.8ex; pad=
ding-left: 1ex; border-left-color: rgb(204, 204, 204); border-left-width: 1=
px; border-left-style: solid;">
<div dir=3D"ltr">
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
Hello, </div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<br>
</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
&nbsp;&nbsp;&nbsp; I have a scenario that I&nbsp;need to execute a program =
from the other directory than my current directory.</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
I got an error when I ran it, and I would like to seek helps and&nbsp;exper=
tises.</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<br>
</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<br>
</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
My current directory is at my_project, and&nbsp;the&nbsp;program that I&nbs=
p;would&nbsp;like&nbsp;to execute is at&nbsp;my_project/vendor/kinectic-sdk=
-rb/kinectic-sdk.rb
</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<br>
</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
In my current directory my_project, I have&nbsp; a test.rb which contains a=
 very simple line of code such as
</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<br>
</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<span>#!/usr/bin/ruby<br>
</span></div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
puts &quot;Hello World!&quot;<br>
</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<span>require File.join (File.expand_path (File.dirname(__FILE__)), 'vendor=
/kinectic-sdk-rb/kinectic-sdk.rb')</span></div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<span><br>
</span></div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<span><br>
</span></div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<span>I tried to run the test.rb at my current directory&nbsp;which is&nbsp=
;my_project , and I got the following error message:</span></div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<span><br>
</span></div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<span>Could not load&nbsp;file kinectic-sdk.rb&nbsp; from my&nbsp;&nbsp;/my=
_project/vendor/kinectic-sdk-rb/kinectic-sdk.rb folder.&nbsp;</span></div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<br>
</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<br>
</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
Thanks for all of your helps,</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
Minh</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<br>
</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<br>
</div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<br>
</div>
<div>
<div id=3D"x_gmail-m_3084731617864670336appendonsend"></div>
<div style=3D"color: rgb(0, 0, 0); font-family: Calibri,Arial,Helvetica,san=
s-serif; font-size: 12pt;">
<br>
</div>
<hr style=3D"width: 98%; display: inline-block;">
<div id=3D"x_gmail-m_3084731617864670336divRplyFwdMsg" dir=3D"ltr"><font co=
lor=3D"#000000" face=3D"Calibri, sans-serif" style=3D"font-size: 11pt;"><b>=
From:</b> ruby-talk &lt;<a href=3D"mailto:[email protected]" =
target=3D"_blank">[email protected]</a>&gt;
 on behalf of Dan Fitzpatrick &lt;<a href=3D"mailto:[email protected]" targ=
et=3D"_blank">[email protected]</a>&gt;<br>
<b>Sent:</b> Friday, October 25, 2019 12:30 AM<br>
<b>To:</b> <a href=3D"mailto:[email protected]" target=3D"_blank">rub=
[email protected]</a> &lt;<a href=3D"mailto:[email protected]" tar=
get=3D"_blank">[email protected]</a>&gt;<br>
<b>Subject:</b> [External] Re: How to compare a hash key with a string valu=
e</font>
<div>&nbsp;</div>
</div>
<div><font size=3D"2"><span style=3D"font-size: 11pt;">
<div>Hello Dun,<br>
<br>
<br>
First I would change the name of your variable &quot;hash&quot; to somethin=
g else <br>
because it is not a hash, it is an array of hashes. Since it represents <br=
>
a list of people, I would call it people.<br>
<br>
<br>
The main issue is that your keys are getting converted to symbols. So <br>
none of the objects have the &quot;width&quot; attribute as a string.<br>
<br>
<br>
This is the only thing that continuously annoys me about Ruby:<br>
<br>
<br>
a =3D <br>
{&quot;label&quot;:&quot;Name&quot;,&quot;value&quot;:&quot;Bob&quot;,&quot=
;identifier&quot;:&quot;field2&quot;,&quot;type&quot;:&quot;oneLineText&quo=
t;,&quot;page&quot;:1,&quot;page_name&quot;:&quot;Step
<br>
1&quot;,&quot;width&quot;:&quot;100%&quot;}<br>
<br>
=3D&gt; {:label=3D&gt;&quot;Name&quot;, :value=3D&gt;&quot;Bob&quot;, :iden=
tifier=3D&gt;&quot;field2&quot;, <br>
:type=3D&gt;&quot;oneLineText&quot;, :page=3D&gt;1, :page_name=3D&gt;&quot;=
Step 1&quot;, :width=3D&gt;&quot;100%&quot;}<br>
<br>
<br>
b <br>
=3D{&quot;label&quot;=3D&gt;&quot;Name&quot;,&quot;value&quot;=3D&gt;&quot;=
Bob&quot;,&quot;identifier&quot;=3D&gt;&quot;field2&quot;,&quot;type&quot;=
=3D&gt;&quot;oneLineText&quot;,&quot;page&quot;=3D&gt;1,&quot;page_name&quo=
t;=3D&gt;&quot;Step
<br>
1&quot;,&quot;width&quot;=3D&gt;&quot;100%&quot;}<br>
=3D&gt; {&quot;label&quot;=3D&gt;&quot;Name&quot;, &quot;value&quot;=3D&gt;=
&quot;Bob&quot;, &quot;identifier&quot;=3D&gt;&quot;field2&quot;, <br>
&quot;type&quot;=3D&gt;&quot;oneLineText&quot;, &quot;page&quot;=3D&gt;1, &=
quot;page_name&quot;=3D&gt;&quot;Step 1&quot;, &quot;width&quot;=3D&gt;&quo=
t;100%&quot;}<br>
<br>
a['width']<br>
<br>
=3D&gt; nil<br>
<br>
b['width']<br>
<br>
=3D&gt; &quot;100%&quot;<br>
<br>
a[:width]<br>
<br>
=3D&gt; &quot;100%&quot;<br>
<br>
<br>
Here is your code working:<br>
<br>
people =3D <br>
[{&quot;label&quot;:&quot;Name&quot;,&quot;value&quot;:&quot;Bob&quot;,&quo=
t;identifier&quot;:&quot;field2&quot;,&quot;type&quot;:&quot;oneLineText&qu=
ot;,&quot;page&quot;:1,&quot;page_name&quot;:&quot;Step
<br>
1&quot;,&quot;width&quot;:&quot;100%&quot;},{&quot;label&quot;:&quot;Email&=
quot;,&quot;value&quot;:&quot;<a href=3D"mailto:[email protected]" target=3D=
"_blank">[email protected]</a>&quot;,&quot;identifier&quot;:&quot;field3&quo=
t;,&quot;type&quot;:&quot;email&quot;,&quot;page&quot;:1,&quot;page_name&qu=
ot;:&quot;Step
<br>
1&quot;,&quot;width&quot;:&quot;100%&quot;},{&quot;label&quot;:&quot;Phone =
<br>
Number&quot;,&quot;value&quot;:&quot;&quot;,&quot;identifier&quot;:&quot;fi=
eld7&quot;,&quot;type&quot;:&quot;oneLineText&quot;,&quot;page&quot;:1,&quo=
t;page_name&quot;:&quot;Step
<br>
1&quot;,&quot;width&quot;:&quot;100%&quot;},{&quot;label&quot;:&quot;Commen=
ts&quot;,&quot;value&quot;:&quot;some information about <br>
the <br>
compagny&quot;,&quot;identifier&quot;:&quot;field5&quot;,&quot;type&quot;:&=
quot;textarea&quot;,&quot;page&quot;:1,&quot;page_name&quot;:&quot;Step <br=
>
1&quot;,&quot;width&quot;:&quot;100%&quot;}]<br>
<br>
<br>
# If you only need the width attribute, you can do this (no loop on the <br=
>
attributes needed):<br>
<br>
people.each_with_index do |person, i|<br>
&nbsp;&nbsp; puts &quot;Person is #{i&#43;1}&quot; # First person displays =
as 1 instead of 0<br>
<br>
&nbsp;&nbsp; puts &quot;The value of width is #{person[:width]}&quot; if pe=
rson.has_key?(:width)<br>
end<br>
<br>
<br>
# If needed, loop through all the attributes of person (like in your <br>
example), but change to detecting symbol keys<br>
<br>
people.each_with_index do |person, i|<br>
&nbsp;&nbsp; puts &quot;Person is #{i&#43;1}&quot; # First person is 1 inst=
ead of 0<br>
<br>
&nbsp;&nbsp; person.each do |key, value|<br>
&nbsp;&nbsp;&nbsp;&nbsp; if key =3D=3D :width<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; puts &quot;The value of width is #{val=
ue}&quot;<br>
&nbsp;&nbsp;&nbsp;&nbsp; end<br>
&nbsp;&nbsp; end<br>
end<br>
<br>
<br>
Also, if you are defining your hashes, you don't need to use JSON format <b=
r>
with quoted keys, you can just do:<br>
<br>
a =3D {label: &quot;Name&quot;, value: &quot;Bob&quot;, identifier: &quot;f=
ield2&quot;, type: <br>
&quot;oneLineText&quot;, page: 1, page_name: &quot;Step 1&quot;, width: &qu=
ot;100%&quot;}<br>
<br>
<br>
Dan<br>
<br>
<br>
On 10/24/2019 1:35 AM, Tran, Minh wrote:<br>
<br>
Unsubscribe: &lt;<a href=3D"mailto:[email protected]?subject=
=3Dunsubscribe" target=3D"_blank">mailto:[email protected]?su=
bject=3Dunsubscribe</a>&gt;<br>
&lt;<a href=3D"http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk=
" target=3D"_blank">http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby=
-talk</a>&gt;<br>
</div>
</span></font></div>
</div>
<br>
<hr>
<font color=3D"gray" face=3D"Arial" size=3D"1"><br>
This e-mail message (including any attachments) is for the sole use of<br>
the intended recipient(s) and may contain confidential and privileged<br>
information. If the reader of this message is not the intended<br>
recipient, you are hereby notified that any dissemination, distribution<br>
or copying of this message (including any attachments) is strictly<br>
prohibited.<br>
<br>
If you have received this message in error, please contact<br>
the sender by reply e-mail message and destroy all copies of the<br>
original message (including attachments).<br>
</font></div>
<br>
Unsubscribe: &lt;mailto:<a href=3D"mailto:[email protected]" =
target=3D"_blank">[email protected]</a>?subject=3Dunsubscribe=
&gt;<br>
&lt;<a href=3D"http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk=
" target=3D"_blank" rel=3D"noreferrer">http://lists.ruby-lang.org/cgi-bin/m=
ailman/options/ruby-talk</a>&gt;<br>
</blockquote>
</div>
</div>
</body>
</html>

--_000_SN6PR05MB53916EF10F581E3A559EB628EE780SN6PR05MB5391namp_--

--===============0329066342==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


Unsubscribe: <mailto:[email protected]?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>

--===============0329066342==--