Class: Kapusta::Reader
- Inherits:
-
Object
- Object
- Kapusta::Reader
- Defined in:
- lib/kapusta/reader.rb
Constant Summary collapse
- WHITESPACE =
[' ', "\t", "\n", "\r", "\f", "\v", ','].freeze
- DELIMS =
['(', ')', '[', ']', '{', '}', '"', ';'].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(source, preserve_comments: false) ⇒ Reader
constructor
A new instance of Reader.
- #read_all ⇒ Object
Constructor Details
#initialize(source, preserve_comments: false) ⇒ Reader
Returns a new instance of Reader.
12 13 14 15 16 |
# File 'lib/kapusta/reader.rb', line 12 def initialize(source, preserve_comments: false) @src = source @pos = 0 @preserve_comments = preserve_comments end |
Class Method Details
.read_all(source, preserve_comments: false) ⇒ Object
8 9 10 |
# File 'lib/kapusta/reader.rb', line 8 def self.read_all(source, preserve_comments: false) new(source, preserve_comments:).read_all end |
Instance Method Details
#read_all ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/kapusta/reader.rb', line 18 def read_all forms = [] loop do skip_ws break if eof? forms << read_next_item end forms end |