Class: ReVIEW::BlockElementNode

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) ⇒ BlockElementNode

Returns a new instance of BlockElementNode.



879
880
881
882
883
884
885
# File 'lib/review/compiler.rb', line 879

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.



889
890
891
# File 'lib/review/compiler.rb', line 889

def args
  @args
end

#compilerObject (readonly)

Returns the value of attribute compiler.



886
887
888
# File 'lib/review/compiler.rb', line 886

def compiler
  @compiler
end

#contentObject (readonly)

Returns the value of attribute content.



890
891
892
# File 'lib/review/compiler.rb', line 890

def content
  @content
end

#nameObject (readonly)

Returns the value of attribute name.



888
889
890
# File 'lib/review/compiler.rb', line 888

def name
  @name
end

#positionObject (readonly)

Returns the value of attribute position.



887
888
889
# File 'lib/review/compiler.rb', line 887

def position
  @position
end

Instance Method Details

#parse_args(*patterns) ⇒ Object



90
91
92
93
94
95
96
97
98
# File 'lib/review/node.rb', line 90

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

#to_docObject



79
80
81
82
83
84
85
86
87
88
# File 'lib/review/node.rb', line 79

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