Class: Metriksd::Data
- Inherits:
-
Object
- Object
- Metriksd::Data
- Defined in:
- lib/metriksd/data.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
readonly
Returns the value of attribute client_id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#payload ⇒ Object
readonly
Returns the value of attribute payload.
-
#time ⇒ Object
readonly
Returns the value of attribute time.
Instance Method Summary collapse
- #[](key) ⇒ Object
-
#initialize(data) ⇒ Data
constructor
A new instance of Data.
Constructor Details
#initialize(data) ⇒ Data
Returns a new instance of Data.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/metriksd/data.rb', line 7 def initialize(data) data = HashWithIndifferentAccess.new(data) unless @time = data.delete(:time) raise ArgumentError, "No 'time' was found" end unless @client_id = data.delete(:client_id) raise ArgumentError, "No 'client_id' was found" end unless @name = data.delete(:name) raise ArgumentError, "No 'name' was found" end @payload = data end |
Instance Attribute Details
#client_id ⇒ Object (readonly)
Returns the value of attribute client_id.
5 6 7 |
# File 'lib/metriksd/data.rb', line 5 def client_id @client_id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/metriksd/data.rb', line 5 def name @name end |
#payload ⇒ Object (readonly)
Returns the value of attribute payload.
5 6 7 |
# File 'lib/metriksd/data.rb', line 5 def payload @payload end |
#time ⇒ Object (readonly)
Returns the value of attribute time.
5 6 7 |
# File 'lib/metriksd/data.rb', line 5 def time @time end |
Instance Method Details
#[](key) ⇒ Object
25 26 27 |
# File 'lib/metriksd/data.rb', line 25 def [](key) @payload[key] end |