Class: JsDuck::Doc::DelimitedParser
- Inherits:
-
Object
- Object
- JsDuck::Doc::DelimitedParser
- Defined in:
- lib/jsduck/doc/delimited_parser.rb
Overview
Helper in parsing the default values and type definitions where we take into account correctly nested parenthesis and strings. But at the same time we don’t care much about the actual contents.
Instance Method Summary collapse
-
#initialize(doc_scanner) ⇒ DelimitedParser
constructor
Initialized with Doc::Scanner instance.
-
#parse_until_close_curly ⇒ Object
Parses until a closing “}”.
-
#parse_until_close_square ⇒ Object
Parses until a closing “]”.
-
#parse_until_space ⇒ Object
Parses until a closing parenthesis or space.
Constructor Details
#initialize(doc_scanner) ⇒ DelimitedParser
Initialized with Doc::Scanner instance
10 11 12 |
# File 'lib/jsduck/doc/delimited_parser.rb', line 10 def initialize(doc_scanner) @ds = doc_scanner end |
Instance Method Details
#parse_until_close_curly ⇒ Object
Parses until a closing “}”.
15 16 17 |
# File 'lib/jsduck/doc/delimited_parser.rb', line 15 def parse_until_close_curly parse_until_close_paren(/\}/, /[^\}]*/) end |
#parse_until_close_square ⇒ Object
Parses until a closing “]”.
20 21 22 |
# File 'lib/jsduck/doc/delimited_parser.rb', line 20 def parse_until_close_square parse_until_close_paren(/\]/, /[^\]]*/) end |
#parse_until_space ⇒ Object
Parses until a closing parenthesis or space.
25 26 27 28 29 30 31 |
# File 'lib/jsduck/doc/delimited_parser.rb', line 25 def parse_until_space begin parse_while(/[^\[\]\{\}\(\)'"\s]/) rescue nil end end |