Class: Languages::Ruby::CommentRuby

Inherits:
Comment
  • Object
show all
Defined in:
lib/kuniri/language/ruby/comment_ruby.rb

Overview

CommentRuby is responsible for handling ruby comments.

Instance Method Summary collapse

Constructor Details

#initializeCommentRuby

Returns a new instance of CommentRuby.



14
15
16
# File 'lib/kuniri/language/ruby/comment_ruby.rb', line 14

def initialize
  @flagMultipleLine = false
end

Instance Method Details

#get_comment(pLine) ⇒ Object

See Also:



19
20
21
22
23
24
25
26
27
28
# File 'lib/kuniri/language/ruby/comment_ruby.rb', line 19

def get_comment(pLine)

  # Single line
  return pLine.scan(/#(.*)/)[0].join if is_single_line_comment?(pLine)

  # Multiple line
  multipleLine = handle_multiple_line(pLine)
  return multipleLine if multipleLine
  return nil
end

#is_multiple_line_comment?(pLine) ⇒ Boolean

Returns:

  • (Boolean)

See Also:



37
38
39
40
# File 'lib/kuniri/language/ruby/comment_ruby.rb', line 37

def is_multiple_line_comment?(pLine)
  return true if (pLine =~ /^=begin(.*?)/ || @flagMultipleLine)
  return false
end

#is_multiple_line_comment_end?(pLine) ⇒ Boolean

Returns:

  • (Boolean)

See Also:



43
44
45
46
# File 'lib/kuniri/language/ruby/comment_ruby.rb', line 43

def is_multiple_line_comment_end?(pLine)
  return true if pLine =~ /^=end/
  return false
end

#is_single_line_comment?(pLine) ⇒ Boolean

Returns:

  • (Boolean)

See Also:



31
32
33
34
# File 'lib/kuniri/language/ruby/comment_ruby.rb', line 31

def is_single_line_comment?(pLine)
  return true if pLine =~ /#(.*)/
  return false
end

#prepare_line_comment(pString) ⇒ Object (protected)

See Also:



51
52
53
54
# File 'lib/kuniri/language/ruby/comment_ruby.rb', line 51

def prepare_line_comment(pString)
  return "" if pString =~ /=begin/
  return pString
end