class DataStructure
DataStructure
. @class_description
A DataStructure type implementation. Implements the DataStructure type interface.
DataStructure
. @class_description
A DataStructure type library's implementation. Implements the DataStructure type interface.
Constants
- TYPES
Private constants.
- VERSION
Public Class Methods
instance?(obj = nil)
click to toggle source
self.instance?(obj = nil). @description
Predicate. Verifies an object is a Array, Hash, Queue, or SizedQueue instance.
@param obj [.]
Any object.
@return [TrueClass, FalseClass]
True in the case the object's class or an ancestor class is Array, Hash, Queue, SizedQueue, or Node. False otherwise.
# File lib/data_structure_impl.rb, line 32 def self.instance?(obj = nil) boolean = false TYPES.each { |type| if (obj.is_a?(type)) boolean = true end } return boolean end
type?(type = nil)
click to toggle source
self.type?(type = nil). @description
Predicate. Verifies a type is a DataStructure type.
@param type [.]
Any type.
@return [TrueClass, FalseClass]
True in the case the type is Array, Hash, Queue, or SizedQueue, or, an ancestor is in the type set. False otherwise.
# File lib/data_structure_impl.rb, line 54 def self.type?(type = nil) element = self.types_element?(type) element_child = self.type_child?(type) boolean = (element || element_child) return boolean end
type_child?(type = nil)
click to toggle source
self.type_child?(type = nil). @description
Predicate. Verifies a type is a data structure type's child.
@param type [.]
Any identifier.
@return [TrueClass, FalseClass]
True in the case a TYPES element is type's ancestor. False otherwise.
# File lib/data_structure_impl.rb, line 82 def self.type_child?(type = nil) boolean = false type_ancestors = type.ancestors() type_ancestors.each { |ancestor| if (types_element?(ancestor) && !types_element?(type)) boolean = true end } return boolean end
types()
click to toggle source
self.types(). @description
Gets the types.
@return [Array]
The TYPES array.
# File lib/data_structure_impl.rb, line 19 def self.types() return TYPES end
types_element?(type = nil)
click to toggle source
self.types_element?(type = nil). @description
Verifies an identifier is a TYPES element.
@param type [.]
Any identifier.
@return [TrueClass, FalseClass]
True in the case the argument is a TYPES element. False otherwise.
# File lib/data_structure_impl.rb, line 70 def self.types_element?(type = nil) boolean = TYPES.include?(type) return boolean end