Class: IniParse::Lines::Comment

Inherits:
Blank
  • Object
show all
Defined in:
lib/iniparse/lines.rb

Overview

Represents a comment. Comment lines begin with a semi-colon or hash.

; this is a comment
# also a comment

Instance Method Summary collapse

Methods inherited from Blank

#blank?, parse

Methods included from Line

#blank?, #initialize, #line_contents, #options, #to_ini

Instance Method Details

#commentObject

Returns the inline comment for this line. Includes the comment separator at the beginning of the string.

In rare cases where a comment seperator appeared in the original file, but without a comment, just the seperator will be returned.



348
349
350
# File 'lib/iniparse/lines.rb', line 348

def comment
  @comment !~ /\S/ ? @comment_sep : super
end

#has_comment?Boolean

Returns if this line has an inline comment.

Being a Comment this will always return true, even if the comment is nil. This would be the case if the line starts with a comment seperator, but has no comment text. See spec/fixtures/smb.ini for a real-world example.

Returns:

  • (Boolean)


338
339
340
# File 'lib/iniparse/lines.rb', line 338

def has_comment?
  true
end