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.
685 686 687 688 |
# File 'lib/maruku/input/parse_span.rb', line 685 def initialize @elements = [] @cur_string = '' end |
Instance Attribute Details
#elements ⇒ Object
Read elements
683 684 685 |
# File 'lib/maruku/input/parse_span.rb', line 683 def elements @elements end |
Instance Method Details
#describe ⇒ Object
731 732 733 734 735 736 737 738 |
# File 'lib/maruku/input/parse_span.rb', line 731 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
710 711 712 |
# File 'lib/maruku/input/parse_span.rb', line 710 def is_end? @cur_string.empty? || @cur_string =~ /\s\z/ end |
#push_char(c) ⇒ Object
721 722 723 |
# File 'lib/maruku/input/parse_span.rb', line 721 def push_char(c) @cur_string << c end |
#push_element(e) ⇒ Object Also known as: push
690 691 692 693 694 695 696 697 |
# File 'lib/maruku/input/parse_span.rb', line 690 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
700 701 702 703 704 705 706 707 708 |
# File 'lib/maruku/input/parse_span.rb', line 700 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
727 728 729 |
# File 'lib/maruku/input/parse_span.rb', line 727 def push_space @cur_string << ' ' unless @cur_string[-1, 1] == ' ' end |
#push_string_if_present ⇒ Object
714 715 716 717 718 719 |
# File 'lib/maruku/input/parse_span.rb', line 714 def push_string_if_present unless @cur_string.empty? @elements << @cur_string @cur_string = '' end end |