Class: WAB::Data

Inherits:
Object
  • Object
show all
Defined in:
lib/wab/data.rb

Overview

The class representing the cananical data structure in WAB. Typically the Data instances are factory created by the Shell and will most likely not be instance of this class but rather a class that is a duck-type of this class (has the same methods and behavior).

Direct Known Subclasses

Impl::Data

Instance Method Summary collapse

Instance Method Details

#deep_dupObject

Make a deep copy of the Data instance.

Raises:

  • (NotImplementedError)


60
61
62
# File 'lib/wab/data.rb', line 60

def deep_dup()
  raise NotImplementedError.new
end

#detectObject

Detects and converts strings to Ruby objects following the rules:

Time

“2017-01-05T15:04:33.123456789Z”, zulu only

UUID

“b0ca922d-372e-41f4-8fea-47d880188ba3”

URI

opo.technology/sample”, HTTP only

Raises:

  • (NotImplementedError)


79
80
81
# File 'lib/wab/data.rb', line 79

def detect()
  raise NotImplementedError.new
end

#eachObject

Each child of the Data instance is provided as an argument to a block when the each method is called.

Raises:

  • (NotImplementedError)


47
48
49
# File 'lib/wab/data.rb', line 47

def each()
  raise NotImplementedError.new
end

#each_leafObject

Each leaf of the Data instance is provided as an argument to a block when the each method is called. A leaf is a primitive that has no children and will be nil, a Boolean, String, Numberic, Time, WAB::UUID, or URI.

Raises:

  • (NotImplementedError)


55
56
57
# File 'lib/wab/data.rb', line 55

def each_leaf()
  raise NotImplementedError.new
end

#get(_path) ⇒ Object

Gets the Data element or value identified by the path where the path elements are separated by the ‘.’ character. The path can also be a array of path node identifiers. For example, child.grandchild is the same as [‘child’, ‘grandchild’].

Raises:

  • (NotImplementedError)


24
25
26
# File 'lib/wab/data.rb', line 24

def get(_path)
  raise NotImplementedError.new
end

#has?(_path) ⇒ Boolean

Returns true if the Data element or value identified by the path exists where the path elements are separated by the ‘.’ character. The path can also be a array of path node identifiers. For example, child.grandchild is the same as [‘child’, ‘grandchild’].

Returns:

  • (Boolean)

Raises:

  • (NotImplementedError)


16
17
18
# File 'lib/wab/data.rb', line 16

def has?(_path)
  raise NotImplementedError.new
end

#json(_indent = 0) ⇒ Object

Encode the data as a JSON string.

Raises:

  • (NotImplementedError)


71
72
73
# File 'lib/wab/data.rb', line 71

def json(_indent=0)
  raise NotImplementedError.new
end

#nativeObject

Returns the instance converted to native Ruby values such as a Hash, Array, etc.

Raises:

  • (NotImplementedError)


66
67
68
# File 'lib/wab/data.rb', line 66

def native()
  raise NotImplementedError.new
end

#set(_path, _value) ⇒ Object

Sets the node value identified by the path where the path elements are separated by the ‘.’ character. The path can also be a array of path node identifiers. For example, child.grandchild is the same as [‘child’, ‘grandchild’]. The value must be one of the allowed data values described in the initialize method.

For arrays, the behavior is similar to an Array#[] with the exception of a negative index less than the negative length in which case the value is prepended (Array#unshift).

path

path to location to be set

value

value to set

repair

flag indicating invalid value should be repaired if possible

Raises:

  • (NotImplementedError)


41
42
43
# File 'lib/wab/data.rb', line 41

def set(_path, _value)
  raise NotImplementedError.new
end