Class: CssRewrite::RegexRewriter
- Inherits:
-
Object
- Object
- CssRewrite::RegexRewriter
- Defined in:
- lib/css-rewrite/regex_rewriter.rb
Instance Attribute Summary collapse
-
#regex ⇒ Object
readonly
Returns the value of attribute regex.
-
#replacement_block ⇒ Object
readonly
Returns the value of attribute replacement_block.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(regex, &block) ⇒ RegexRewriter
constructor
A new instance of RegexRewriter.
- #matches?(url) ⇒ Boolean
- #rewrite(url, filename) ⇒ Object
Constructor Details
#initialize(regex, &block) ⇒ RegexRewriter
Returns a new instance of RegexRewriter.
9 10 11 12 |
# File 'lib/css-rewrite/regex_rewriter.rb', line 9 def initialize(regex, &block) @regex = regex @replacement_block = block end |
Instance Attribute Details
#regex ⇒ Object (readonly)
Returns the value of attribute regex.
7 8 9 |
# File 'lib/css-rewrite/regex_rewriter.rb', line 7 def regex @regex end |
#replacement_block ⇒ Object (readonly)
Returns the value of attribute replacement_block.
7 8 9 |
# File 'lib/css-rewrite/regex_rewriter.rb', line 7 def replacement_block @replacement_block end |
Class Method Details
.applies_to?(*args, &block) ⇒ Boolean
3 4 5 |
# File 'lib/css-rewrite/regex_rewriter.rb', line 3 def self.applies_to?(*args, &block) args.size == 1 && args.first.is_a?(Regexp) && block_given? end |
Instance Method Details
#matches?(url) ⇒ Boolean
14 15 16 |
# File 'lib/css-rewrite/regex_rewriter.rb', line 14 def matches?(url) !!(regex =~ url) end |
#rewrite(url, filename) ⇒ Object
18 19 20 |
# File 'lib/css-rewrite/regex_rewriter.rb', line 18 def rewrite(url, filename) replacement_block.call(url, filename) end |