Class: Rutty::Node
Overview
A wrapper class representing an individual node. Normally contained by Nodes.
Class Method Summary collapse
-
.load_config(dir) ⇒ void
Override the inherited Config.load_config method, raising an exception to indicate improper usage.
Instance Method Summary collapse
- #<=>(other) ⇒ Integer
-
#==(other) ⇒ Boolean
Checks for object eqality.
-
#has_tag?(tag) ⇒ Boolean
Whether this object’s tags array includes the specified tag.
-
#initialize(data, defaults = {}) ⇒ Node
constructor
Initialize a new Node instance by merging the user-provided data with the configured defaults.
Methods inherited from Config
#[], #[]=, #method_missing, #to_hash, #update!
Constructor Details
#initialize(data, defaults = {}) ⇒ Node
Initialize a new Rutty::Node instance by merging the user-provided data with the configured defaults.
31 32 33 34 |
# File 'lib/rutty/node.rb', line 31 def initialize data, defaults = {} merged_data = defaults.merge data super merged_data end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Rutty::Config
Class Method Details
.load_config(dir) ⇒ void
Override the inherited Config.load_config method, raising an exception to indicate improper usage.
19 20 21 |
# File 'lib/rutty/node.rb', line 19 def load_config dir raise "Unable to call load_config on Node objects." end |
Instance Method Details
#<=>(other) ⇒ Integer
Relation of this Rutty::Node to another Rutty::Node. Used for sorting. Compares the host property of the nodes, as it’s the only property guaranteed to be set and unique.
53 54 55 |
# File 'lib/rutty/node.rb', line 53 def <=> other self.host <=> other.host end |
#==(other) ⇒ Boolean
Checks for object eqality. Checks each property of this Rutty::Node against the other.
62 63 64 65 66 67 68 |
# File 'lib/rutty/node.rb', line 62 def == other self.host == other.host and self.port == other.port and self.user == other.user and self.keypath == other.keypath and self. == other. end |
#has_tag?(tag) ⇒ Boolean
Whether this object’s tags array includes the specified tag.
40 41 42 43 |
# File 'lib/rutty/node.rb', line 40 def has_tag? tag return false if self..nil? self..include? tag end |