Class: Clustr::Node
- Inherits:
-
Object
- Object
- Clustr::Node
- Defined in:
- lib/clustr/node.rb
Overview
Represents a single node within a cluster. Note that the physical entity represented by this node may occur several times in other Cluster.
Instance Attribute Summary collapse
-
#created ⇒ Object
readonly
Returns the value of attribute created.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#properties ⇒ Object
readonly
Returns the value of attribute properties.
Instance Method Summary collapse
-
#[](key) ⇒ mixed
Retrieves a specific key from the property set that accompanies this node.
- #initialize(id, properties = {}) ⇒ Node constructor
Constructor Details
#initialize(id, properties = {}) ⇒ Node
Creates a new Clustr::Node, taking a unique identifier for the node within the Cluster and a set of optional, properties to further describe or provide additional information about the node.
16 17 18 19 20 |
# File 'lib/clustr/node.rb', line 16 def initialize(id, properties = {}) @id = id @created = Time.now.to_i @properties = properties end |
Instance Attribute Details
#created ⇒ Object (readonly)
Returns the value of attribute created.
7 8 9 |
# File 'lib/clustr/node.rb', line 7 def created @created end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
7 8 9 |
# File 'lib/clustr/node.rb', line 7 def id @id end |
#properties ⇒ Object (readonly)
Returns the value of attribute properties.
7 8 9 |
# File 'lib/clustr/node.rb', line 7 def properties @properties end |
Instance Method Details
#[](key) ⇒ mixed
Retrieves a specific key from the property set that accompanies this node.
28 29 30 |
# File 'lib/clustr/node.rb', line 28 def [](key) properties[key.to_s] end |