Class: Markie::Rule
- Inherits:
-
Object
- Object
- Markie::Rule
- Defined in:
- lib/markie/rule.rb
Instance Attribute Summary collapse
-
#regex ⇒ Object
readonly
Returns the value of attribute regex.
Instance Method Summary collapse
- #applies_to?(markdown) ⇒ Boolean
-
#initialize(regex:, tokenize_rule:) ⇒ Rule
constructor
A new instance of Rule.
- #tokenize(markdown) ⇒ Object
Constructor Details
#initialize(regex:, tokenize_rule:) ⇒ Rule
Returns a new instance of Rule.
5 6 7 8 |
# File 'lib/markie/rule.rb', line 5 def initialize(regex:, tokenize_rule:) @regex = regex @tokenize_rule = tokenize_rule end |
Instance Attribute Details
#regex ⇒ Object (readonly)
Returns the value of attribute regex.
3 4 5 |
# File 'lib/markie/rule.rb', line 3 def regex @regex end |
Instance Method Details
#applies_to?(markdown) ⇒ Boolean
10 11 12 |
# File 'lib/markie/rule.rb', line 10 def applies_to?(markdown) regex.match?(markdown[0]) end |
#tokenize(markdown) ⇒ Object
14 15 16 |
# File 'lib/markie/rule.rb', line 14 def tokenize(markdown) tokenize_rule.call(markdown, regex) end |