Class: Yuriita::Route
- Inherits:
-
Object
- Object
- Yuriita::Route
- Defined in:
- lib/yuriita/route.rb
Instance Attribute Summary collapse
-
#collection ⇒ Object
readonly
Returns the value of attribute collection.
Instance Method Summary collapse
- #action ⇒ Object
-
#initialize(collection, matcher, to) ⇒ Route
constructor
A new instance of Route.
- #match?(input) ⇒ Boolean
Constructor Details
#initialize(collection, matcher, to) ⇒ Route
Returns a new instance of Route.
5 6 7 8 9 |
# File 'lib/yuriita/route.rb', line 5 def initialize(collection, matcher, to) @collection = collection @matcher = matcher @to = to end |
Instance Attribute Details
#collection ⇒ Object (readonly)
Returns the value of attribute collection.
3 4 5 |
# File 'lib/yuriita/route.rb', line 3 def collection @collection end |
Instance Method Details
#action ⇒ Object
29 30 31 |
# File 'lib/yuriita/route.rb', line 29 def action to end |
#match?(input) ⇒ Boolean
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/yuriita/route.rb', line 11 def match?(input) case matcher when String # TODO better matching # This won't work for string matching becuase to_s will use quotes # Could we parse it and compare the queries? This would maybe let us # catch parse exceptions # # If we do parse the matcher we could warn if it resulted in more than # two inputs. input.to_s == matcher when Proc matcher.call(input) else matcher.match?(input) end end |