Class: Saxon::XPath::VariableDeclaration

Inherits:
Object
  • Object
show all
Defined in:
lib/saxon/xpath/variable_declaration.rb

Overview

Represents an XPath variable declaration in the static context of a compiled XPath, providing an idiomatic Ruby way to deal with these.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ VariableDeclaration

Returns a new instance of VariableDeclaration.

Parameters:

  • opts (Hash) (defaults to: {})

Options Hash (opts):

Raises:



17
18
19
20
21
# File 'lib/saxon/xpath/variable_declaration.rb', line 17

def initialize(opts = {})
  raise VariableDeclarationError, opts.keys if opts.keys.length > 2
  @qname = opts.fetch(:qname)
  @item_type, @occurrences = extract_type_decl(opts.reject { |k, v| k == :qname })
end

Instance Attribute Details

#item_typeSaxon::ItemType (readonly)

Returns:



11
12
13
# File 'lib/saxon/xpath/variable_declaration.rb', line 11

def item_type
  @item_type
end

#occurrencesnet.sf.saxon.s9api.OccurrenceIndicator (readonly)

Returns:



13
14
15
# File 'lib/saxon/xpath/variable_declaration.rb', line 13

def occurrences
  @occurrences
end

#qnameSaxon::QName (readonly)

Returns:



9
10
11
# File 'lib/saxon/xpath/variable_declaration.rb', line 9

def qname
  @qname
end

Instance Method Details

#==(other) ⇒ Boolean

VariableDeclarations compare equal if their qname, item_type, and occurrences are equal

Parameters:

  • other (Saxon::VariableDeclaration)

Returns:

  • (Boolean)


26
27
28
# File 'lib/saxon/xpath/variable_declaration.rb', line 26

def ==(other)
  VariableDeclaration === other && qname == other.qname && item_type == other.item_type && occurrences == other.occurrences
end

#compiler_argsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



31
32
33
# File 'lib/saxon/xpath/variable_declaration.rb', line 31

def compiler_args
  [qname.to_java, item_type.to_java, occurrences]
end