Sha256: 74bf1654b4fd2d34e1c3ee99136d54e680eb9fbd83ab32e41ac689988b7691bc

Contents?: true

Size: 821 Bytes

Versions: 51

Compression:

Stored size: 821 Bytes

Contents

require 'bel_parser/parsers/ast/node'
require 'bel_parser/quoting'
require 'concurrent/hash'
require_relative '../state_function'

module BELParser
  module Script
    module State
      class DocumentProperty
        extend StateFunction
        extend BELParser::Quoting

        TARGET_NODE = BELParser::Parsers::AST::DocumentProperty

        def self.consume(ast_node, script_context)
          return nil unless ast_node.is_a?(TARGET_NODE)
          hash = script_context[:document_properties] ||= Concurrent::Hash.new

          name, value = ast_node.children
          if name && value
            name_string  = name.identifier.string_literal
            value_string = value.children[0].string_literal
            hash[name_string] = unquote(value_string)
          end
        end
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
bel_parser-1.0.0.alpha.46-java lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.46 lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.45-java lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.45 lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.44-java lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.44 lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.43-java lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.43 lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.42-java lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.42 lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.41-java lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.41 lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.40-java lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.40 lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.39-java lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.39 lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.38-java lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.38 lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.37-java lib/bel_parser/script/state/document_property.rb
bel_parser-1.0.0.alpha.37 lib/bel_parser/script/state/document_property.rb