Class: OrigenTesters::Decompiler::Pattern::VectorDelimiterBase
- Inherits:
-
Object
- Object
- OrigenTesters::Decompiler::Pattern::VectorDelimiterBase
- Defined in:
- lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb
Instance Attribute Summary collapse
-
#current_vector ⇒ Object
readonly
Returns the value of attribute current_vector.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #comment_start ⇒ Object
- #current_vector! ⇒ Object
- #delimited? ⇒ Boolean
- #in_comment_block? ⇒ Boolean
- #include_last_line? ⇒ Boolean
-
#initialize(parent) ⇒ VectorDelimiterBase
constructor
A new instance of VectorDelimiterBase.
- #shift(line) ⇒ Object
Constructor Details
#initialize(parent) ⇒ VectorDelimiterBase
Returns a new instance of VectorDelimiterBase.
8 9 10 11 12 13 14 |
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 8 def initialize(parent) @current_vector = [] @delimited = false @in_comment_block = false @parent = parent end |
Instance Attribute Details
#current_vector ⇒ Object (readonly)
Returns the value of attribute current_vector.
5 6 7 |
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 5 def current_vector @current_vector end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
6 7 8 |
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 6 def parent @parent end |
Instance Method Details
#comment_start ⇒ Object
16 17 18 |
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 16 def comment_start parent.comment_start end |
#current_vector! ⇒ Object
56 57 58 |
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 56 def current_vector! current_vector.join('') end |
#delimited? ⇒ Boolean
60 61 62 |
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 60 def delimited? @delimited end |
#in_comment_block? ⇒ Boolean
20 21 22 |
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 20 def in_comment_block? @in_comment_block end |
#include_last_line? ⇒ Boolean
64 65 66 |
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 64 def include_last_line? @include_last_line end |
#shift(line) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/origen_testers/decompiler/pattern/vector_delimiter_base.rb', line 24 def shift(line) if @in_comment_block if !line.strip.start_with?(comment_start) # End of the comment block. # Signal that this vector is over, but don't include the # newly shifted line. @delimited = true @include_last_line = false else @current_vector << line end else if current_vector.empty? && line.strip.start_with?(comment_start) # Currently in an empty vector and encountered a comment. # Start a new comment block. @in_comment_block = true @current_vector << line elsif !current_vector.empty? && line.strip.start_with?(comment_start) # Not in an empty vector, but not in a comment block. # Signal the end of this vector and start a new one with # this vector. @delimited = true @include_last_line = false else # Standard single vector @delimited = true @include_last_line = true @current_vector << line end end end |