Class: Turbo::PathRule
- Inherits:
-
Object
- Object
- Turbo::PathRule
- Defined in:
- lib/turbo/path_configuration/path_rule.rb
Instance Attribute Summary collapse
-
#patterns ⇒ Object
Array of regular expressions to match against.
-
#properties ⇒ Object
The properties to apply for matches.
Instance Method Summary collapse
- #initWithRule(rule) ⇒ Object
-
#match(path) ⇒ Object
Returns true if any pattern in this rule matches ‘path`.
-
#subscript(key) ⇒ Object
Convenience method to retrieve a String value for a key Access ‘properties` directly to get a different type.
Instance Attribute Details
#patterns ⇒ Object
Array of regular expressions to match against
4 5 6 |
# File 'lib/turbo/path_configuration/path_rule.rb', line 4 def patterns @patterns end |
#properties ⇒ Object
The properties to apply for matches
7 8 9 |
# File 'lib/turbo/path_configuration/path_rule.rb', line 7 def properties @properties end |
Instance Method Details
#initWithRule(rule) ⇒ Object
15 16 17 18 19 |
# File 'lib/turbo/path_configuration/path_rule.rb', line 15 def initWithRule(rule) self.patterns = rule["patterns"] self.properties = rule["properties"] self end |
#match(path) ⇒ Object
Returns true if any pattern in this rule matches ‘path`
22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/turbo/path_configuration/path_rule.rb', line 22 def match(path) patterns.each do |pattern| #guard let regex = try? NSRegularExpression(pattern: pattern) else { continue } regex = %r(#{pattern}) if path =~ regex return true end end false end |
#subscript(key) ⇒ Object
Convenience method to retrieve a String value for a key Access ‘properties` directly to get a different type
11 12 13 |
# File 'lib/turbo/path_configuration/path_rule.rb', line 11 def subscript(key) properties[key].to_s end |