Class: SpecTag

Inherits:
Object show all
Defined in:
lib/mspec/runner/tag.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string = nil) ⇒ SpecTag

Returns a new instance of SpecTag.



4
5
6
# File 'lib/mspec/runner/tag.rb', line 4

def initialize(string=nil)
  parse(string) if string
end

Instance Attribute Details

#commentObject

Returns the value of attribute comment.



2
3
4
# File 'lib/mspec/runner/tag.rb', line 2

def comment
  @comment
end

#descriptionObject

Returns the value of attribute description.



2
3
4
# File 'lib/mspec/runner/tag.rb', line 2

def description
  @description
end

#tagObject

Returns the value of attribute tag.



2
3
4
# File 'lib/mspec/runner/tag.rb', line 2

def tag
  @tag
end

Instance Method Details

#==(o) ⇒ Object



17
18
19
# File 'lib/mspec/runner/tag.rb', line 17

def ==(o)
  @tag == o.tag and @comment == o.comment and @description == o.description
end

#parse(string) ⇒ Object



8
9
10
11
# File 'lib/mspec/runner/tag.rb', line 8

def parse(string)
  m = /^([^()#:]+)(\(([^)]+)?\))?:(.*)/.match string
  @tag, @comment, @description = m.values_at(1, 3, 4) if m
end

#to_sObject



13
14
15
# File 'lib/mspec/runner/tag.rb', line 13

def to_s
  "#{@tag}#{ "(#{@comment})" if @comment }:#{@description}"
end