Class: LicenseFinder::License::Matcher
- Inherits:
-
Struct
- Object
- Struct
- LicenseFinder::License::Matcher
- Defined in:
- lib/license_finder/license/matcher.rb
Instance Attribute Summary collapse
-
#regexp ⇒ Object
Returns the value of attribute regexp.
Class Method Summary collapse
-
.from_regex(regexp) ⇒ Object
an alias for Matcher.new, for uniformity of constructors.
- .from_template(template) ⇒ Object
- .from_text(text) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#regexp ⇒ Object
Returns the value of attribute regexp
3 4 5 |
# File 'lib/license_finder/license/matcher.rb', line 3 def regexp @regexp end |
Class Method Details
.from_regex(regexp) ⇒ Object
an alias for Matcher.new, for uniformity of constructors
13 14 15 |
# File 'lib/license_finder/license/matcher.rb', line 13 def self.from_regex(regexp) new(regexp) end |
.from_template(template) ⇒ Object
4 5 6 |
# File 'lib/license_finder/license/matcher.rb', line 4 def self.from_template(template) from_text(template.content) end |
.from_text(text) ⇒ Object
8 9 10 |
# File 'lib/license_finder/license/matcher.rb', line 8 def self.from_text(text) from_regex(Text.compile_to_regex(text)) end |
Instance Method Details
#matches_text?(text) ⇒ Boolean
17 18 19 |
# File 'lib/license_finder/license/matcher.rb', line 17 def matches_text?(text) !!(Text.normalize_punctuation(text) =~ regexp) end |