Class: MetaCommit::Extension::MarkdownSupport::Models::Ast
- Inherits:
-
Contracts::Ast
- Object
- Contracts::Ast
- MetaCommit::Extension::MarkdownSupport::Models::Ast
- Defined in:
- lib/meta_commit_markdown_support/models/ast.rb
Overview
Adapter which implements MetaCommit::Contracts::Ast contract and wraps CommonMarker::Node
Instance Attribute Summary collapse
-
#element ⇒ CommonMarker::Node
The current value of element.
Instance Method Summary collapse
- #==(right_ast) ⇒ Boolean
-
#children ⇒ Array<MetaCommit::Contracts::Ast>
Children ast.
-
#first_column ⇒ Integer?
Column number where ast starts.
-
#first_line ⇒ Integer?
Line number where ast starts.
-
#initialize(element) ⇒ Ast
constructor
A new instance of Ast.
-
#last_column ⇒ Integer?
Column number where ast ends.
-
#last_line ⇒ Integer?
Line number where ast ends.
Constructor Details
#initialize(element) ⇒ Ast
Returns a new instance of Ast.
8 9 10 |
# File 'lib/meta_commit_markdown_support/models/ast.rb', line 8 def initialize(element) @element = element end |
Instance Attribute Details
#element ⇒ CommonMarker::Node
Returns the current value of element.
4 5 6 |
# File 'lib/meta_commit_markdown_support/models/ast.rb', line 4 def element @element end |
Instance Method Details
#==(right_ast) ⇒ Boolean
43 44 45 |
# File 'lib/meta_commit_markdown_support/models/ast.rb', line 43 def ==(right_ast) element == right_ast.element end |
#children ⇒ Array<MetaCommit::Contracts::Ast>
Returns children ast.
13 14 15 16 17 |
# File 'lib/meta_commit_markdown_support/models/ast.rb', line 13 def children element.each.map do |child| Ast.new(child) end end |
#first_column ⇒ Integer?
Returns column number where ast starts.
30 31 32 33 |
# File 'lib/meta_commit_markdown_support/models/ast.rb', line 30 def first_column return nil if element.sourcepos[:start_column].nil? element.sourcepos[:start_column] - 1 end |
#first_line ⇒ Integer?
Returns line number where ast starts.
20 21 22 |
# File 'lib/meta_commit_markdown_support/models/ast.rb', line 20 def first_line element.sourcepos[:start_line] end |
#last_column ⇒ Integer?
Returns column number where ast ends.
36 37 38 39 |
# File 'lib/meta_commit_markdown_support/models/ast.rb', line 36 def last_column return nil if element.sourcepos[:end_column].nil? element.sourcepos[:end_column] - 1 end |
#last_line ⇒ Integer?
Returns line number where ast ends.
25 26 27 |
# File 'lib/meta_commit_markdown_support/models/ast.rb', line 25 def last_line element.sourcepos[:end_line] end |