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.
602 603 604 605 |
# File 'lib/maruku/input/parse_span.rb', line 602 def initialize @elements = [] @cur_string = '' end |
Instance Attribute Details
#elements ⇒ Object
Read elements
600 601 602 |
# File 'lib/maruku/input/parse_span.rb', line 600 def elements @elements end |
Instance Method Details
#describe ⇒ Object
648 649 650 651 652 653 654 655 |
# File 'lib/maruku/input/parse_span.rb', line 648 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
627 628 629 |
# File 'lib/maruku/input/parse_span.rb', line 627 def is_end? @cur_string.empty? || @cur_string =~ /\s\z/ end |
#push_char(c) ⇒ Object
638 639 640 |
# File 'lib/maruku/input/parse_span.rb', line 638 def push_char(c) @cur_string << c end |
#push_element(e) ⇒ Object Also known as: push
607 608 609 610 611 612 613 614 |
# File 'lib/maruku/input/parse_span.rb', line 607 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
617 618 619 620 621 622 623 624 625 |
# File 'lib/maruku/input/parse_span.rb', line 617 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
644 645 646 |
# File 'lib/maruku/input/parse_span.rb', line 644 def push_space @cur_string << ' ' unless @cur_string[-1, 1] == ' ' end |
#push_string_if_present ⇒ Object
631 632 633 634 635 636 |
# File 'lib/maruku/input/parse_span.rb', line 631 def push_string_if_present unless @cur_string.empty? @elements << @cur_string @cur_string = '' end end |