Skip to content

Commit

Permalink
Variable to ts linkeddata#355
Browse files Browse the repository at this point in the history
  • Loading branch information
joepio committed Oct 17, 2019
1 parent e419e0a commit 0fc3a24
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 34 deletions.
36 changes: 25 additions & 11 deletions src/variable.js → src/variable.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,34 @@
'use strict'
import ClassOrder from './class-order'
import Node from './node'
import * as Uri from './uri'
import { TermType } from './types'

/**
* Variables are placeholders used in patterns to be matched.
* In cwm they are symbols which are the formula's list of quantified variables.
* In sparql they are not visibly URIs. Here we compromise, by having
* a common special base URI for variables. Their names are uris,
* but the ? notation has an implicit base uri of 'varid:'
* @class Variable
*/
* Variables are placeholders used in patterns to be matched.
* In cwm they are symbols which are the formula's list of quantified variables.
* In sparql they are not visibly URIs. Here we compromise, by having
* a common special base URI for variables. Their names are uris,
* but the ? notation has an implicit base uri of 'varid:'
*/
export default class Variable extends Node {
constructor (name = '') {
termType: TermType.Variable
static termType: TermType.Variable = TermType.Variable

/**
* The base string for a variable's name
*/
base: string;
/**
* The unique identifier of this variable
*/
uri: string;
/**
* Initializes this variable
* @param name The variable's name
*/
constructor (name: string = '') {
super()
this.termType = Variable.termType
this.termType = TermType.Variable
this.value = name
this.base = 'varid:'
this.uri = Uri.join(name, this.base)
Expand All @@ -40,6 +54,6 @@ export default class Variable extends Node {
}
}

Variable.termType = 'Variable'
Variable.termType = "Variable"
Variable.prototype.classOrder = ClassOrder['Variable']
Variable.prototype.isVar = true
23 changes: 0 additions & 23 deletions types-temp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,6 @@ import { NamedNode } from './src';
// TypeScript Version: 3.0
// Acknowledgements: This work has been financed by Logilab SA, FRANCE, logilab.fr

/**
* Variables are placeholders used in patterns to be matched.
* In cwm they are symbols which are the formula's list of quantified variables.
* In sparql they are not visibly URIs. Here we compromise, by having
* a common special base URI for variables. Their names are uris,
* but the ? notation has an implicit base uri of 'varid:'
*/
export interface Variable extends Node {
/**
* The base string for a variable's name
*/
base: string;
/**
* The unique identifier of this variable
*/
uri: string;
/**
* Initializes this variable
* @param name The variable's name
*/
constructor(name?: string);
static termType: string;
}
/**
* The RDF default graph
*/
Expand Down

0 comments on commit 0fc3a24

Please sign in to comment.