Class: HelpAnywhere::Routes

Inherits:
Object
  • Object
show all
Defined in:
lib/help-anywhere/configuration.rb

Constant Summary collapse

DEFAULTS_ROUTES =
[['/', '_root'], ['??', '$1']]

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeRoutes

Returns a new instance of Routes.



44
45
46
47
# File 'lib/help-anywhere/configuration.rb', line 44

def initialize
  @match_data = []
  @ignore_data = []
end

Instance Attribute Details

#ignore_dataObject

Returns the value of attribute ignore_data.



42
43
44
# File 'lib/help-anywhere/configuration.rb', line 42

def ignore_data
  @ignore_data
end

#match_dataObject

Returns the value of attribute match_data.



42
43
44
# File 'lib/help-anywhere/configuration.rb', line 42

def match_data
  @match_data
end

Instance Method Details

#match(regexp, result) ⇒ Object



49
50
51
# File 'lib/help-anywhere/configuration.rb', line 49

def match regexp, result
  self.match_data << [ regexp, result ]
end

#to_javascriptObject



63
64
65
66
67
68
69
70
71
72
73
# File 'lib/help-anywhere/configuration.rb', line 63

def to_javascript
  arr = self.match_data + DEFAULTS_ROUTES

  output = "HelpAnywhere.add_routes(["
  output += arr.map{ |x| "[/#{x[0].source}/, '#{x[1].sub('\'', '\\\'')}']" }.join(',')
  output += "]);"

  #output += "HelpAnywhere.ignore(["

  output
end

#to_json(*args) ⇒ Object

def ignore regexp

self.ignore_data << [ regexp, result ]

end



57
58
59
60
61
# File 'lib/help-anywhere/configuration.rb', line 57

def to_json *args
  arr = self.match_data + DEFAULTS_ROUTES

  arr.to_json
end