Class: Regenerate::ParsedRegenerateCommentLine

Inherits:
Object
  • Object
show all
Defined in:
lib/regenerate/web-page.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(line, match) ⇒ ParsedRegenerateCommentLine

Returns a new instance of ParsedRegenerateCommentLine.



179
180
181
182
183
184
185
186
187
188
189
# File 'lib/regenerate/web-page.rb', line 179

def initialize(line, match)
  @hasCommentStart = match[1] != ""
  @sectionStart = match[2] != ""
  @isInstanceVar = match[4] != ""
  @name = match[3]
  @value = match[6]
  @sectionEnd = match[7] != ""
  @hasCommentEnd = match[8] != ""
  @line = line
  @isEmptySection = @sectionStart && @sectionEnd
end

Instance Attribute Details

#hasCommentEndObject (readonly)

Returns the value of attribute hasCommentEnd.



176
177
178
# File 'lib/regenerate/web-page.rb', line 176

def hasCommentEnd
  @hasCommentEnd
end

#hasCommentStartObject (readonly)

Returns the value of attribute hasCommentStart.



176
177
178
# File 'lib/regenerate/web-page.rb', line 176

def hasCommentStart
  @hasCommentStart
end

#isEmptySectionObject (readonly)

Returns the value of attribute isEmptySection.



177
178
179
# File 'lib/regenerate/web-page.rb', line 177

def isEmptySection
  @isEmptySection
end

#isInstanceVarObject (readonly)

Returns the value of attribute isInstanceVar.



176
177
178
# File 'lib/regenerate/web-page.rb', line 176

def isInstanceVar
  @isInstanceVar
end

#lineObject (readonly)

Returns the value of attribute line.



177
178
179
# File 'lib/regenerate/web-page.rb', line 177

def line
  @line
end

#nameObject (readonly)

Returns the value of attribute name.



177
178
179
# File 'lib/regenerate/web-page.rb', line 177

def name
  @name
end

#sectionEndObject (readonly)

Returns the value of attribute sectionEnd.



176
177
178
# File 'lib/regenerate/web-page.rb', line 176

def sectionEnd
  @sectionEnd
end

#sectionStartObject (readonly)

Returns the value of attribute sectionStart.



176
177
178
# File 'lib/regenerate/web-page.rb', line 176

def sectionStart
  @sectionStart
end

#valueObject (readonly)

Returns the value of attribute value.



177
178
179
# File 'lib/regenerate/web-page.rb', line 177

def value
  @value
end

Instance Method Details

#checkIsValidObject

only call this method if isRejennerCommentLine returns true



212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
# File 'lib/regenerate/web-page.rb', line 212

def checkIsValid
  if !@isInstanceVar and !["ruby", "class"].include?(@name)
    raiseParseException("Unknown section name #{@name.inspect}")
  end
  if @isEmptySection and (!@hasCommentStart && !@hasCommentEnd)
    raiseParseException("Empty section, but is not a closed comment")
  end
  if !@sectionStart && !@hasCommentEnd
    raiseParseException("End of section in comment start")
  end
  if !@sectionEnd && !@hasCommentStart
    raiseParseException("Start of section in comment end")
  end
  if (@sectionStart && @sectionEnd) && isRuby
    raiseParseException("Empty ruby section")
  end
end

#instanceVarNameObject



203
204
205
# File 'lib/regenerate/web-page.rb', line 203

def instanceVarName
  return @name
end

#isRejennerCommentLineObject



195
196
197
# File 'lib/regenerate/web-page.rb', line 195

def isRejennerCommentLine
  return (@hasCommentStart || @hasCommentEnd) && (@sectionStart || @sectionEnd)
end

#isRubyObject



199
200
201
# File 'lib/regenerate/web-page.rb', line 199

def isRuby
  !@isInstanceVar && @name == "ruby"
end

#raiseParseException(message) ⇒ Object

Raises:



207
208
209
# File 'lib/regenerate/web-page.rb', line 207

def raiseParseException(message)
  raise ParseException.new("Error parsing line #{@line.inspect}: #{message}")
end

#to_sObject



191
192
193
# File 'lib/regenerate/web-page.rb', line 191

def to_s
  "#{@hasCommentStart ? "<!-- ":""}#{@sectionStart ? "[ ":""}#{@isInstanceVar ? "@ ":""}#{@name.inspect}#{@value ? " "+@value:""}#{@sectionEnd ? " ]":""}#{@hasCommentEnd ? " -->":""}"
end