Class: Redirect::Data
- Inherits:
-
Object
- Object
- Redirect::Data
- Defined in:
- lib/redirect/redirect.rb
Instance Attribute Summary collapse
-
#catch_url ⇒ Object
readonly
Returns the value of attribute catch_url.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#match ⇒ Object
readonly
Returns the value of attribute match.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(catch_url, redirect_url, options = {}) ⇒ Data
constructor
A new instance of Data.
- #matches?(url) ⇒ Boolean
- #redirect_url ⇒ Object
Constructor Details
#initialize(catch_url, redirect_url, options = {}) ⇒ Data
Returns a new instance of Data.
30 31 32 33 34 35 |
# File 'lib/redirect/redirect.rb', line 30 def initialize(catch_url, redirect_url, = {}) @catch_url = catch_url @redirect_url = redirect_url @code = [:code] || Redirect.default_code @name = [:name] end |
Instance Attribute Details
#catch_url ⇒ Object (readonly)
Returns the value of attribute catch_url.
29 30 31 |
# File 'lib/redirect/redirect.rb', line 29 def catch_url @catch_url end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
29 30 31 |
# File 'lib/redirect/redirect.rb', line 29 def code @code end |
#match ⇒ Object (readonly)
Returns the value of attribute match.
29 30 31 |
# File 'lib/redirect/redirect.rb', line 29 def match @match end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
29 30 31 |
# File 'lib/redirect/redirect.rb', line 29 def name @name end |
Instance Method Details
#matches?(url) ⇒ Boolean
37 38 39 40 41 |
# File 'lib/redirect/redirect.rb', line 37 def matches?(url) matched = url.match(catch_url) @match = $1 matched end |
#redirect_url ⇒ Object
43 44 45 46 47 48 49 |
# File 'lib/redirect/redirect.rb', line 43 def redirect_url if @match @redirect_url.gsub('$1', @match) else @redirect_url end end |