Class: MaRuKu::In::Markdown::SpanLevelParser::SpanContext
- Inherits:
-
Object
- Object
- MaRuKu::In::Markdown::SpanLevelParser::SpanContext
- Defined in:
- lib/maruku/input/parse_span.rb
Overview
read link
Instance Attribute Summary collapse
-
#elements ⇒ Object
Read elements.
Instance Method Summary collapse
- #describe ⇒ Object
-
#initialize ⇒ SpanContext
constructor
A new instance of SpanContext.
- #is_end? ⇒ Boolean
- #push_char(c) ⇒ Object
- #push_element(e) ⇒ Object (also: #push)
- #push_elements(a) ⇒ Object
-
#push_space ⇒ Object
push space into current string if there isn’t one.
- #push_string_if_present ⇒ Object
Constructor Details
#initialize ⇒ SpanContext
Returns a new instance of SpanContext.
603 604 605 606 |
# File 'lib/maruku/input/parse_span.rb', line 603 def initialize @elements = [] @cur_string = '' end |
Instance Attribute Details
#elements ⇒ Object
Read elements
601 602 603 |
# File 'lib/maruku/input/parse_span.rb', line 601 def elements @elements end |
Instance Method Details
#describe ⇒ Object
649 650 651 652 653 654 655 656 |
# File 'lib/maruku/input/parse_span.rb', line 649 def describe lines = @elements.map{|x| x.inspect }.join("\n") s = "Elements read in span: \n" + lines.gsub(/^/, ' -') + "\n" s += "Current string: \n #{@cur_string.inspect}\n" unless @cur_string.empty? s end |
#is_end? ⇒ Boolean
628 629 630 |
# File 'lib/maruku/input/parse_span.rb', line 628 def is_end? @cur_string.empty? || @cur_string =~ /\s\z/ end |
#push_char(c) ⇒ Object
639 640 641 |
# File 'lib/maruku/input/parse_span.rb', line 639 def push_char(c) @cur_string << c end |
#push_element(e) ⇒ Object Also known as: push
608 609 610 611 612 613 614 615 |
# File 'lib/maruku/input/parse_span.rb', line 608 def push_element(e) raise "Only MDElement and String, please. You pushed #{e.class}: #{e.inspect} " unless e.kind_of?(String) || e.kind_of?(MaRuKu::MDElement) push_string_if_present @elements << e end |
#push_elements(a) ⇒ Object
618 619 620 621 622 623 624 625 626 |
# File 'lib/maruku/input/parse_span.rb', line 618 def push_elements(a) a.each do |e| if e.kind_of? String @cur_string << e else push_element e end end end |
#push_space ⇒ Object
push space into current string if there isn’t one
645 646 647 |
# File 'lib/maruku/input/parse_span.rb', line 645 def push_space @cur_string << ' ' unless @cur_string[-1, 1] == ' ' end |
#push_string_if_present ⇒ Object
632 633 634 635 636 637 |
# File 'lib/maruku/input/parse_span.rb', line 632 def push_string_if_present unless @cur_string.empty? @elements << @cur_string @cur_string = '' end end |