Class: Nasl::String

Inherits:
Node
  • Object
show all
Includes:
Comparable
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.



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

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.



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

def text
  @text
end

#typeObject (readonly)

Returns the value of attribute type.



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

def type
  @type
end

Instance Method Details

#<=>(other) ⇒ Object



41
42
43
# File 'lib/nasl/parser/string.rb', line 41

def <=>(other)
  self.text <=> other.text
end

#to_xml(xml) ⇒ Object



45
46
47
# File 'lib/nasl/parser/string.rb', line 45

def to_xml(xml)
  xml.method_missing(@type.downcase, @text)
end