Class: ReVIEW::CodeBlockElementNode

Inherits:
Node show all
Defined in:
lib/review/node.rb,
lib/review/compiler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Node

#inspect, #to_json, #to_raw, #to_s_by

Constructor Details

#initialize(compiler, position, name, args, content) ⇒ CodeBlockElementNode

Returns a new instance of CodeBlockElementNode.



913
914
915
916
917
918
919
# File 'lib/review/compiler.rb', line 913

def initialize(compiler, position, name, args, content)
  @compiler = compiler
  @position = position
  @name = name
  @args = args
  @content = content
end

Instance Attribute Details

#argsObject (readonly)

Returns the value of attribute args.



923
924
925
# File 'lib/review/compiler.rb', line 923

def args
  @args
end

#compilerObject (readonly)

Returns the value of attribute compiler.



920
921
922
# File 'lib/review/compiler.rb', line 920

def compiler
  @compiler
end

#contentObject (readonly)

Returns the value of attribute content.



924
925
926
# File 'lib/review/compiler.rb', line 924

def content
  @content
end

#nameObject (readonly)

Returns the value of attribute name.



922
923
924
# File 'lib/review/compiler.rb', line 922

def name
  @name
end

#positionObject (readonly)

Returns the value of attribute position.



921
922
923
# File 'lib/review/compiler.rb', line 921

def position
  @position
end

Instance Method Details

#parse_args(*patterns) ⇒ Object



114
115
116
117
118
119
120
121
122
# File 'lib/review/node.rb', line 114

def parse_args(*patterns)
  patterns.map.with_index do |pattern, i|
    if @args[i]
      @args[i].__send__("to_#{pattern}")
    else
      nil
    end
  end
end

#raw_linesObject



124
125
126
# File 'lib/review/node.rb', line 124

def raw_lines
  self.content.to_doc.split(/\n/)
end

#to_docObject



103
104
105
106
107
108
109
110
111
112
# File 'lib/review/node.rb', line 103

def to_doc
  # content_str = super
  args = @args.map(&:to_doc)
  if @content
    content_lines = raw_lines
  else
    content_lines = nil
  end
  @compiler.compile_command(@name, @args, content_lines, self)
end