Class: JayAPI::Elasticsearch::Stats::Node::Storage
- Inherits:
-
Object
- Object
- JayAPI::Elasticsearch::Stats::Node::Storage
- Defined in:
- lib/jay_api/elasticsearch/stats/node/storage.rb
Overview
Holds storage information related to one of the nodes in the Elasticsearch cluster.
Constant Summary collapse
- TOTAL_KEY =
'total_in_bytes'
- FREE_KEY =
'free_in_bytes'
- AVAILABLE_KEY =
'available_in_bytes'
Instance Method Summary collapse
-
#+(other) ⇒ self
A new instance of the class with the added storage of the receiver and
other
. -
#available ⇒ Integer
The total number of bytes that are available on the node.
-
#free ⇒ Integer
The total number of bytes that are free on the node.
-
#initialize(data) ⇒ Storage
constructor
A new instance of Storage.
-
#total ⇒ Integer
The total size of the storage (in bytes).
Constructor Details
#initialize(data) ⇒ Storage
Returns a new instance of Storage.
15 16 17 |
# File 'lib/jay_api/elasticsearch/stats/node/storage.rb', line 15 def initialize(data) @data = data end |
Instance Method Details
#+(other) ⇒ self
Returns A new instance of the class with the added storage of the receiver and other
.
38 39 40 41 42 43 44 45 46 |
# File 'lib/jay_api/elasticsearch/stats/node/storage.rb', line 38 def +(other) raise ArgumentError, "Cannot add #{self.class} and #{other.class} together" unless other.is_a?(self.class) self.class.new( TOTAL_KEY => total + other.total, FREE_KEY => free + other.free, AVAILABLE_KEY => available + other.available ) end |
#available ⇒ Integer
Returns The total number of bytes that are available on the node. In general this is equal to #free, but not always.
32 33 34 |
# File 'lib/jay_api/elasticsearch/stats/node/storage.rb', line 32 def available @available ||= data[AVAILABLE_KEY] end |
#free ⇒ Integer
Returns The total number of bytes that are free on the node.
26 27 28 |
# File 'lib/jay_api/elasticsearch/stats/node/storage.rb', line 26 def free @free ||= data[FREE_KEY] end |
#total ⇒ Integer
Returns The total size of the storage (in bytes).
20 21 22 |
# File 'lib/jay_api/elasticsearch/stats/node/storage.rb', line 20 def total @total ||= data[TOTAL_KEY] end |