# Logstash ruby conditions and referrence

**URL:** https://discuss.elastic.co/t/logstash-ruby-conditions-and-referrence/168784
**Category:** Logstash
**Created:** [February 18, 2019, 8:40am UTC](https://discuss.elastic.co/t/logstash-ruby-conditions-and-referrence/168784 "2019-02-18T08:40:48Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![fedwe](https://avatars.discourse-cdn.com/v4/letter/f/a88e4f/32.png) [@fedwe](https://discuss.elastic.co/u/fedwe)
#### Post date: [February 18, 2019, 8:40am UTC](https://discuss.elastic.co/t/logstash-ruby-conditions-and-referrence/168784/1 "2019-02-18T08:40:48Z")

</div>

hello i am still new in ruby coding and i want to ask how can i apply these conditions in ruby and my case is that i receive different numbers from different countries like +962123456 or 00962123456 or 962123456.i have a csv file that has all country codes with their country name so i want to extract the country code from the number and then use hash to link it to csv file and add its country name field

and these aaare my conditions i want to implement in ruby

if (length(calling)==7)

calling="0" calling;

else if ((length(calling)\>8)&& (substr(calling,1,2) !="00") && (substr(calling,1,3) !="961") )

calling= calling;

else if (substr(calling,1,4) =="9612")

calling ="0" substr(calling,4) ;

else calling=calling;

if (length(called)==7)

called="0" called;

else if ((length(called)\>8)&& (substr(called,1,2) !="00") && (substr(called,1,3) !="961") )

called= called;

else if (substr(called,1,4) =="9612")

called ="0" substr(called,4) ;

else called=called;

if (substr (calling,1,3)=="961")

calling=substr (calling,4);

while(substr(calling,1,1)=="0")

calling = substr(calling,2);

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [March 18, 2019, 8:40am UTC](https://discuss.elastic.co/t/logstash-ruby-conditions-and-referrence/168784/2 "2019-03-18T08:40:54Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
