Class: Nasl::Array

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

Instance Attribute Summary collapse

Attributes inherited from Node

#ctx, #tokens

Instance Method Summary collapse

Methods inherited from Node

#context, #region, #to_xml

Constructor Details

#initialize(tree, *tokens) ⇒ Array

Returns a new instance of Array.



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/nasl/parser/array.rb', line 33

def initialize(tree, *tokens)
  super

  @pairs = if @tokens[1].is_a? ::Array then @tokens[1] else [] end

  @keys = Hash[@pairs.map do |p|
    if p.key.is_a? String
      k = p.key.text
    elsif p.key.is_a? Identifier
      k = p.key.name
    else
      k = p.key.value
    end

    [k, p.value]
  end]

  @children << :pairs
end

Instance Attribute Details

#keysObject (readonly)

Returns the value of attribute keys.



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

def keys
  @keys
end

#pairsObject (readonly)

Returns the value of attribute pairs.



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

def pairs
  @pairs
end