Class: PATokenProxyOptions

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(p_options) ⇒ PATokenProxyOptions

Returns a new instance of PATokenProxyOptions.



18
19
20
21
22
# File 'lib/pa_proxies/pa_token_proxy_options.rb', line 18

def initialize(p_options)
  self.options_hash = p_options
  self.indices_hash = {}
  reset
end

Instance Attribute Details

#indices_hashObject

Returns the value of attribute indices_hash.



3
4
5
# File 'lib/pa_proxies/pa_token_proxy_options.rb', line 3

def indices_hash
  @indices_hash
end

#options_hashObject

Returns the value of attribute options_hash.



2
3
4
# File 'lib/pa_proxies/pa_token_proxy_options.rb', line 2

def options_hash
  @options_hash
end

Class Method Details

.new_if_needed(p_options) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/pa_proxies/pa_token_proxy_options.rb', line 5

def self.new_if_needed(p_options)
  if (p_options.is_a? PATokenProxyOptions)
    return p_options
  else  
    return self.new(p_options)
  end
end

Instance Method Details

#get_current_index(array) ⇒ Object



24
25
26
# File 'lib/pa_proxies/pa_token_proxy_options.rb', line 24

def get_current_index(array)
  return indices_hash[array.object_id.to_s]
end

#inc_index(array) ⇒ Object



28
29
30
31
32
33
# File 'lib/pa_proxies/pa_token_proxy_options.rb', line 28

def inc_index(array)
  indices_hash[array.object_id.to_s] = indices_hash[array.object_id.to_s] + 1
  if indices_hash[array.object_id.to_s] >= array.length
    indices_hash[array.object_id.to_s]= 0
  end
end

#resetObject



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

def reset
  calculate_indices(options_hash) if !@added_indices
  @added_indices = true
end