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.



897
898
899
900
901
902
903
# File 'lib/review/compiler.rb', line 897

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.



907
908
909
# File 'lib/review/compiler.rb', line 907

def args
  @args
end

#compilerObject (readonly)

Returns the value of attribute compiler.



904
905
906
# File 'lib/review/compiler.rb', line 904

def compiler
  @compiler
end

#contentObject (readonly)

Returns the value of attribute content.



908
909
910
# File 'lib/review/compiler.rb', line 908

def content
  @content
end

#nameObject (readonly)

Returns the value of attribute name.



906
907
908
# File 'lib/review/compiler.rb', line 906

def name
  @name
end

#positionObject (readonly)

Returns the value of attribute position.



905
906
907
# File 'lib/review/compiler.rb', line 905

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