Sha256: 16eae91455d34ae652ff78347912206f9c61801c9cc8766f93d8630a490661f1

Contents?: true

Size: 952 Bytes

Versions: 10

Compression:

Stored size: 952 Bytes

Contents

module Jazzy
  class SourceMark
    attr_accessor :name
    attr_accessor :has_start_dash
    attr_accessor :has_end_dash

    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

    def empty?
      !name && !has_start_dash && !has_end_dash
    end

    def copy(other)
      self.name = other.name
      self.has_start_dash = other.has_start_dash
      self.has_end_dash = other.has_end_dash
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
jazzy-0.12.0 lib/jazzy/source_mark.rb
jazzy-0.11.2 lib/jazzy/source_mark.rb
jazzy-0.11.1 lib/jazzy/source_mark.rb
jazzy-0.11.0 lib/jazzy/source_mark.rb
jazzy-0.10.0 lib/jazzy/source_mark.rb
jazzy-0.9.6 lib/jazzy/source_mark.rb
jazzy-0.9.5 lib/jazzy/source_mark.rb
jazzy-0.9.4 lib/jazzy/source_mark.rb
jazzy-0.9.3 lib/jazzy/source_mark.rb
jazzy-0.9.2 lib/jazzy/source_mark.rb