Class: Nanoc::Extra::SrcsetParser Private
- Inherits:
-
Object
- Object
- Nanoc::Extra::SrcsetParser
- Defined in:
- lib/nanoc/extra/srcset_parser.rb
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Classes: InvalidFormat
Constant Summary collapse
- REGEX_REST =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/ ( # Zero or one of the following: ( # A width descriptor, consisting of: \s+ # ASCII whitespace \d+ # a valid non-negative integer w # a U+0077 LATIN SMALL LETTER W character ) | ( # A pixel density descriptor, consisting of \s+ # ASCII whitespace (\d*\.)?\d+ # a valid floating-point number x # and a U+0078 LATIN SMALL LETTER X character. ) )* /x
Instance Method Summary collapse
- #call ⇒ Object private
-
#initialize(value) ⇒ SrcsetParser
constructor
private
A new instance of SrcsetParser.
Constructor Details
#initialize(value) ⇒ SrcsetParser
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of SrcsetParser.
30 31 32 |
# File 'lib/nanoc/extra/srcset_parser.rb', line 30 def initialize(value) @value = value end |
Instance Method Details
#call ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/nanoc/extra/srcset_parser.rb', line 34 def call matches = [] loop do match = {} scan(/\s*/) match[:url] = scan(/[^, ]+/) match[:rest] = scan(REGEX_REST) scan(/\s*/) matches << match next if try_scan(/,/) break if eos? raise(InvalidFormat) end matches rescue InvalidFormat @value end |