Class: Nasl::String

Inherits:
Node
  • Object
show all
Defined in:
lib/nasl/parser/string.rb

Instance Attribute Summary collapse

Attributes inherited from Node

#ctx, #tokens

Instance Method Summary collapse

Methods inherited from Node

#context, #region

Constructor Details

#initialize(tree, *tokens) ⇒ String

Returns a new instance of String.



33
34
35
36
37
38
# File 'lib/nasl/parser/string.rb', line 33

def initialize(tree, *tokens)
  super

  @text = @tokens.first.body
  @type = @tokens.first.type
end

Instance Attribute Details

#textObject (readonly)

Returns the value of attribute text.



31
32
33
# File 'lib/nasl/parser/string.rb', line 31

def text
  @text
end

#typeObject (readonly)

Returns the value of attribute type.



31
32
33
# File 'lib/nasl/parser/string.rb', line 31

def type
  @type
end

Instance Method Details

#to_xml(xml) ⇒ Object



40
41
42
43
44
45
46
# File 'lib/nasl/parser/string.rb', line 40

def to_xml(xml)
  if @type == :DATA
    xml.data(@text)
  else
    xml.string(@text)
  end
end