Class: BridgetownInlineSvg::Markup
- Inherits:
-
Object
- Object
- BridgetownInlineSvg::Markup
- Defined in:
- lib/bridgetown-inline-svg/markup.rb
Constant Summary collapse
- PATH_SYNTAX =
Separate file path from other attributes
/ ^(?<path>[^\s"']+|"[^"]+"|'[^']+') (?<params>.*) /x.freeze
- PARAM_SYNTAX =
Parse the first parameter in a string, giving :
[full_match, param_name, double_quoted_val, single_quoted_val, unquoted_val]
The Regex works like :
-
first group
- match a group of characters that is alphanumeric, _ or -.
-
second group (non-capturing OR)
- match a double-quoted string - match a single-quoted string - match an unquoted string matching the set : [\w\.\-#]
-
/ ([\w-]+)\s*=\s* (?:"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'|([\w.\-#]+)) /x.freeze
Instance Attribute Summary collapse
-
#markup ⇒ Object
readonly
Returns the value of attribute markup.
Class Method Summary collapse
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(markup) ⇒ Markup
constructor
A new instance of Markup.
Constructor Details
#initialize(markup) ⇒ Markup
Returns a new instance of Markup.
31 32 33 |
# File 'lib/bridgetown-inline-svg/markup.rb', line 31 def initialize(markup) @markup = markup end |
Instance Attribute Details
#markup ⇒ Object (readonly)
Returns the value of attribute markup.
4 5 6 |
# File 'lib/bridgetown-inline-svg/markup.rb', line 4 def markup @markup end |
Class Method Details
.parse(markup) ⇒ Object
27 28 29 |
# File 'lib/bridgetown-inline-svg/markup.rb', line 27 def self.parse(markup) new(markup).call end |
Instance Method Details
#call ⇒ Object
35 36 37 38 39 |
# File 'lib/bridgetown-inline-svg/markup.rb', line 35 def call raise_exception! unless matched [path, params] end |