Class: Jazzy::SourceMark
- Inherits:
-
Object
- Object
- Jazzy::SourceMark
- Defined in:
- lib/jazzy/source_mark.rb
Instance Attribute Summary collapse
-
#has_end_dash ⇒ Object
Returns the value of attribute has_end_dash.
-
#has_start_dash ⇒ Object
Returns the value of attribute has_start_dash.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #copy(other) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(mark_string = nil) ⇒ SourceMark
constructor
A new instance of SourceMark.
Constructor Details
#initialize(mark_string = nil) ⇒ SourceMark
Returns a new instance of SourceMark.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/jazzy/source_mark.rb', line 7 def initialize(mark_string = nil) return unless mark_string # Format: 'MARK: - NAME -' with dashes optional mark_string.sub!(/^MARK: /, '') if mark_string.empty? # Empty return elsif mark_string == '-' # Separator self.has_start_dash = true return end self.has_start_dash = mark_string.start_with?('- ') self.has_end_dash = mark_string.end_with?(' -') start_index = has_start_dash ? 2 : 0 end_index = has_end_dash ? -3 : -1 self.name = mark_string[start_index..end_index] end |
Instance Attribute Details
#has_end_dash ⇒ Object
Returns the value of attribute has_end_dash.
5 6 7 |
# File 'lib/jazzy/source_mark.rb', line 5 def has_end_dash @has_end_dash end |
#has_start_dash ⇒ Object
Returns the value of attribute has_start_dash.
4 5 6 |
# File 'lib/jazzy/source_mark.rb', line 4 def has_start_dash @has_start_dash end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/jazzy/source_mark.rb', line 3 def name @name end |
Instance Method Details
#copy(other) ⇒ Object
35 36 37 38 39 |
# File 'lib/jazzy/source_mark.rb', line 35 def copy(other) self.name = other.name self.has_start_dash = other.has_start_dash self.has_end_dash = other.has_end_dash end |
#empty? ⇒ Boolean
31 32 33 |
# File 'lib/jazzy/source_mark.rb', line 31 def empty? !name && !has_start_dash && !has_end_dash end |