Class: HelpAnywhere::Routes
- Inherits:
-
Object
- Object
- HelpAnywhere::Routes
- Defined in:
- lib/help-anywhere/configuration.rb
Constant Summary collapse
- DEFAULTS_ROUTES =
[['/', '_root'], ['??', '$1']]
Instance Attribute Summary collapse
-
#ignore_data ⇒ Object
Returns the value of attribute ignore_data.
-
#match_data ⇒ Object
Returns the value of attribute match_data.
Instance Method Summary collapse
-
#initialize ⇒ Routes
constructor
A new instance of Routes.
- #match(regexp, result) ⇒ Object
- #to_javascript ⇒ Object
-
#to_json(*args) ⇒ Object
def ignore regexp self.ignore_data << [ regexp, result ] end.
Constructor Details
#initialize ⇒ Routes
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_data ⇒ Object
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_data ⇒ Object
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_javascript ⇒ Object
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 |