Class: ActiveRemote::Cached::ArgumentKeys

Inherits:
Object
  • Object
show all
Defined in:
lib/active_remote/cached/argument_keys.rb

Constant Summary collapse

REMOVE_CHARACTERS =
/[[:space:]+=><{}\[\];:\-,]/
REPLACE_MAP =
[
  [' ', 'SP'],
  ['+', 'PL'],
  ['=', 'EQ'],
  ['>', 'GT'],
  ['<', 'LT'],
  ['{', 'LB'],
  ['}', 'RB'],
  ['[', 'LB2'],
  [']', 'RB2'],
  [';', 'SC'],
  [':', 'CO'],
  ['-', 'DA'],
  [',', 'COM']
].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*arguments, options) ⇒ ArgumentKeys

Returns a new instance of ArgumentKeys.



23
24
25
26
27
28
29
30
31
# File 'lib/active_remote/cached/argument_keys.rb', line 23

def initialize(*arguments, options)
  @options = options
  @arguments = arguments.flatten.compact
  @argument_string = ''

  @arguments.each do |argument|
    @argument_string << argument.to_s
  end
end

Instance Attribute Details

#argument_stringObject (readonly)

Returns the value of attribute argument_string.



4
5
6
# File 'lib/active_remote/cached/argument_keys.rb', line 4

def argument_string
  @argument_string
end

#argumentsObject (readonly)

Returns the value of attribute arguments.



4
5
6
# File 'lib/active_remote/cached/argument_keys.rb', line 4

def arguments
  @arguments
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/active_remote/cached/argument_keys.rb', line 4

def options
  @options
end

Instance Method Details

#cache_keyObject



33
34
35
36
37
38
39
40
41
42
43
# File 'lib/active_remote/cached/argument_keys.rb', line 33

def cache_key
  return @argument_string.gsub(REMOVE_CHARACTERS, '') if remove_characters?

  if replace_characters?
    REPLACE_MAP.each do |character, replacement|
      @argument_string.gsub!(character, replacement)
    end
  end

  @argument_string
end

#to_sObject



45
46
47
# File 'lib/active_remote/cached/argument_keys.rb', line 45

def to_s
  cache_key
end