class Jazzy::SourceMark
Attributes
has_end_dash[RW]
has_start_dash[RW]
name[RW]
Public Class Methods
new(mark_string = nil)
click to toggle source
# File lib/jazzy/source_mark.rb, line 9 def initialize(mark_string = nil) return unless mark_string # Format: 'MARK: - NAME -' with dashes optional mark_content = mark_string.sub(/^MARK: /, '') if mark_content.empty? # Empty return elsif mark_content == '-' # Separator self.has_start_dash = true return end self.has_start_dash = mark_content.start_with?('- ') self.has_end_dash = mark_content.end_with?(' -') start_index = has_start_dash ? 2 : 0 end_index = has_end_dash ? -3 : -1 self.name = mark_content[start_index..end_index] end
new_generic_requirements(requirements)
click to toggle source
# File lib/jazzy/source_mark.rb, line 33 def self.new_generic_requirements(requirements) marked_up = requirements.gsub(/\b([^=:]\S*)\b/, '`\1`') text = "Available where #{marked_up}" new(text) end
Public Instance Methods
can_merge?(other)
click to toggle source
Can we merge the contents of another mark into our own?
# File lib/jazzy/source_mark.rb, line 50 def can_merge?(other) other.empty? || other.name == name end
copy(other)
click to toggle source
# File lib/jazzy/source_mark.rb, line 43 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?()
click to toggle source
# File lib/jazzy/source_mark.rb, line 39 def empty? !name && !has_start_dash && !has_end_dash end