Class: MaRuKu::In::Markdown::SpanLevelParser::CharSourceStrscan
- Inherits:
-
Object
- Object
- MaRuKu::In::Markdown::SpanLevelParser::CharSourceStrscan
- Includes:
- MaRuKu::In::Markdown::SpanLevelParser, Strings
- Defined in:
- lib/maruku/input/charsource.rb,
lib/maruku/input/charsource.rb
Overview
a wrapper around StringScanner
Constant Summary
Constants included from Strings
Strings::Abbreviation, Strings::AttributeDefinitionList, Strings::Definition, Strings::EMailAddress, Strings::FootnoteText, Strings::HeaderWithAttributes, Strings::HeaderWithId, Strings::IncompleteLink, Strings::LinkRegex, Strings::MightBeTableHeader, Strings::Sep, Strings::TabSize, Strings::TableSeparator, Strings::URL
Constants included from MaRuKu::In::Markdown::SpanLevelParser
CharSource, EscapedCharInInlineCode, EscapedCharInQuotes, EscapedCharInText, R_REF_ID, SPACE
Instance Method Summary collapse
- #consume_whitespace ⇒ Object
-
#cur_char ⇒ Object
Return current char as a FixNum (or nil).
-
#cur_chars(n) ⇒ Object
Return the next n chars as a String.
- #cur_chars_are(string) ⇒ Object
- #current_remaining_buffer ⇒ Object
- #describe ⇒ Object
- #ignore_char ⇒ Object
- #ignore_chars(n) ⇒ Object
-
#initialize(s) ⇒ CharSourceStrscan
constructor
A new instance of CharSourceStrscan.
-
#next_char ⇒ Object
Return the char after current char as a FixNum (or nil).
- #next_matches(r) ⇒ Object
- #read_regexp(r) ⇒ Object
- #shift_char ⇒ Object
Methods included from Strings
#add_tabs, #dbg_describe_ary, #force_linebreak?, #line_md_type, #normalize_key_and_value, #num_leading_hashes, #number_of_leading_spaces, #parse_email_headers, #spaces_before_first_char, #split_lines, #strip_hashes, #strip_indent, #unquote
Methods included from MaRuKu::In::Markdown::SpanLevelParser
#describe_pos, #is_ial, #md_al, #parse_lines_as_span, #parse_span_better, #read_attribute_list, #read_em, #read_email_el, #read_emstrong, #read_footnote_ref, #read_image, #read_inline_code, #read_inline_html, #read_link, #read_quoted, #read_quoted_or_unquoted, #read_ref_id, #read_server_directive, #read_simple, #read_span, #read_strong, #read_url, #read_url_el, #unit_tests_for_attribute_lists
Methods included from Helpers
#md_abbr, #md_abbr_def, #md_ald, #md_br, #md_code, #md_codeblock, #md_el, #md_em, #md_email, #md_emstrong, #md_entity, #md_foot_ref, #md_footnote, #md_header, #md_hrule, #md_html, #md_ial, #md_im_image, #md_im_link, #md_image, #md_li, #md_link, #md_par, #md_quote, #md_ref_def, #md_server, #md_strong, #md_url
Constructor Details
#initialize(s) ⇒ CharSourceStrscan
Returns a new instance of CharSourceStrscan.
202 203 204 |
# File 'lib/maruku/input/charsource.rb', line 202 def initialize(s) @s = StringScanner.new(s) end |
Instance Method Details
#consume_whitespace ⇒ Object
257 258 259 260 |
# File 'lib/maruku/input/charsource.rb', line 257 def consume_whitespace @s.scan /\s+/ nil end |
#cur_char ⇒ Object
Return current char as a FixNum (or nil).
207 208 209 |
# File 'lib/maruku/input/charsource.rb', line 207 def cur_char @s.peek(1)[0] end |
#cur_chars(n) ⇒ Object
Return the next n chars as a String.
212 213 214 |
# File 'lib/maruku/input/charsource.rb', line 212 def cur_chars(n); @s.peek(n) end |
#cur_chars_are(string) ⇒ Object
239 240 241 |
# File 'lib/maruku/input/charsource.rb', line 239 def cur_chars_are(string) cur_chars(string.size) == string end |
#current_remaining_buffer ⇒ Object
235 236 237 |
# File 'lib/maruku/input/charsource.rb', line 235 def current_remaining_buffer @s.rest #nil #@buffer[@buffer_index, @buffer.size-@buffer_index] end |
#describe ⇒ Object
262 263 264 |
# File 'lib/maruku/input/charsource.rb', line 262 def describe describe_pos(@s.string, @s.pos) end |
#ignore_char ⇒ Object
225 226 227 228 |
# File 'lib/maruku/input/charsource.rb', line 225 def ignore_char @s.get_byte nil end |
#ignore_chars(n) ⇒ Object
230 231 232 233 |
# File 'lib/maruku/input/charsource.rb', line 230 def ignore_chars(n) n.times do @s.get_byte end nil end |
#next_char ⇒ Object
Return the char after current char as a FixNum (or nil).
217 218 219 |
# File 'lib/maruku/input/charsource.rb', line 217 def next_char; @s.peek(2)[1] end |
#next_matches(r) ⇒ Object
243 244 245 246 |
# File 'lib/maruku/input/charsource.rb', line 243 def next_matches(r) len = @s.match?(r) return !!len end |
#read_regexp(r) ⇒ Object
248 249 250 251 252 253 254 255 |
# File 'lib/maruku/input/charsource.rb', line 248 def read_regexp(r) string = @s.scan(r) if string return r.match(string) else return nil end end |
#shift_char ⇒ Object
221 222 223 |
# File 'lib/maruku/input/charsource.rb', line 221 def shift_char (@s.get_byte)[0] end |