Class: CommentUnit::CommentPart

Inherits:
Object
  • Object
show all
Defined in:
lib/comment_part.rb

Direct Known Subclasses

ExecutablePart

Constant Summary collapse

@@mapping =
nil
@@matcher =
nil
@@subclasses =
[]

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



7
8
9
# File 'lib/comment_part.rb', line 7

def content
  @content
end

Class Method Details

.parse(comment_string) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/comment_part.rb', line 10

def self.parse(comment_string)
  previous_part = nil
  comment_string.inject([]) do |results, line|
    part = parse_part(line)
    if (!previous_part.nil? && previous_part.can_combine?(part))
      previous_part.combine_with(part)
    else 
      unless part.nil?
        results << part 
        previous_part = part
      end
    end
    results
  end
end

Instance Method Details

#can_combine?(another) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/comment_part.rb', line 30

def can_combine?(another)
  false
end

#combine_with(another) ⇒ Object



34
35
36
# File 'lib/comment_part.rb', line 34

def combine_with(another)
  @content << ';' << another.content
end

#to_sObject



26
27
28
# File 'lib/comment_part.rb', line 26

def to_s
"#{self.class}[#{@content}]"
end