Class: Propolize::SpecialChunk

Inherits:
LinesChunk show all
Defined in:
lib/propolize.rb

Overview

Special chunk contains a name and an optional value examples - “##appendix”, “##date 23 May, 2014” “##author John Smith”

Instance Attribute Summary collapse

Attributes inherited from LinesChunk

#lines

Instance Method Summary collapse

Methods inherited from LinesChunk

#addLine, #postProcess

Constructor Details

#initialize(name, line) ⇒ SpecialChunk

Returns a new instance of SpecialChunk.



762
763
764
765
# File 'lib/propolize.rb', line 762

def initialize(name, line)
  super(line)
  @name = name
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



761
762
763
# File 'lib/propolize.rb', line 761

def name
  @name
end

Instance Method Details

#getDocumentComponentObject



776
777
778
779
780
781
782
# File 'lib/propolize.rb', line 776

def getDocumentComponent
  if name == "appendix"
    return StartAppendix.new() # special "start appendix" command, or, 
  else
    return DocumentProperty.new(name, lines.join("\n")) # a named property value
  end
end

#isTerminatedBy?(line) ⇒ Boolean

“special chunk” is terminated by a blank line, or by the start of the next special chunk

Returns:

  • (Boolean)


772
773
774
# File 'lib/propolize.rb', line 772

def isTerminatedBy?(line)
  return (/^\#\#/.match(line) or /^\s*$/.match(line))
end

#to_sObject



767
768
769
# File 'lib/propolize.rb', line 767

def to_s
  return "SpecialChunk: (#{name}) #{lines.inspect}"
end