Class: MockSearch

Inherits:
Object
  • Object
show all
Defined in:
lib/mock_search.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(site, env, cabotage) ⇒ MockSearch

Returns a new instance of MockSearch.



7
8
9
10
11
# File 'lib/mock_search.rb', line 7

def initialize(site,env,cabotage)
  @site  = site 
  @host  = generar_host(site,env)
  @cabotage = (cabotage=='true')
end

Instance Attribute Details

#adtObject (readonly)

Returns the value of attribute adt.



5
6
7
# File 'lib/mock_search.rb', line 5

def adt
  @adt
end

#cabotageObject (readonly)

Returns the value of attribute cabotage.



5
6
7
# File 'lib/mock_search.rb', line 5

def cabotage
  @cabotage
end

#cnnObject (readonly)

Returns the value of attribute cnn.



5
6
7
# File 'lib/mock_search.rb', line 5

def cnn
  @cnn
end

#hostObject (readonly)

Returns the value of attribute host.



5
6
7
# File 'lib/mock_search.rb', line 5

def host
  @host
end

#infObject (readonly)

Returns the value of attribute inf.



5
6
7
# File 'lib/mock_search.rb', line 5

def inf
  @inf
end

Instance Method Details

#generar_host(site, env) ⇒ Object



13
14
15
16
# File 'lib/mock_search.rb', line 13

def generar_host(site,env)
 	host = YAML.load(File.open("host.yml"))
 	return host[site][env]
end

#generate_post_alert_urlObject



32
33
34
# File 'lib/mock_search.rb', line 32

def generate_post_alert_url()
  return @host + "/subscriptions-ui/subscriptions/price-alert-by-month/add"
end

#get_childrensObject



36
37
38
# File 'lib/mock_search.rb', line 36

def get_childrens
  @cnn + @inf
end

#passengersObject



18
19
20
21
22
23
# File 'lib/mock_search.rb', line 18

def passengers()
@adt = [1,2,3][rand(3)]
	@cnn = [0,1,2][rand(@adt)]
	@inf = [0,1,2][rand(@adt-@cnn)]   
	return "#{@adt}/#{@cnn}/#{@inf}"
end

#set_from_city(code) ⇒ Object



40
41
42
# File 'lib/mock_search.rb', line 40

def set_from_city(code)
  @city_from_1 = MockCity.new(@site,code)
end

#set_to_city(code) ⇒ Object



44
45
46
# File 'lib/mock_search.rb', line 44

def set_to_city(code)
  @city_to_1 = MockCity.new(@site,code)
end

#to_city_change(site) ⇒ Object



25
26
27
28
29
30
# File 'lib/mock_search.rb', line 25

def to_city_change(site)
	unless site == @site
		@to_city = MockCity.new(site)
		@path    = @path.gsub(/^...\/...\//,"#{@from_city.code}/#{@to_city.code}/")
	end	
end