Class: VagrantCloud::Data
- Inherits:
-
Object
- Object
- VagrantCloud::Data
- Defined in:
- lib/vagrant_cloud/data.rb
Overview
Generic data class which provides simple attribute data storage using a Hash like interface
Direct Known Subclasses
Defined Under Namespace
Classes: Immutable, Mutable, NilClass
Constant Summary collapse
- Nil =
Easy to use constant to access general use instance of our custom nil class
NilClass.instance
Instance Method Summary collapse
-
#[](k) ⇒ Object
Fetch value from data.
-
#initialize(**opts) ⇒ Data
constructor
Create a new instance.
- #inspect ⇒ String
Constructor Details
#initialize(**opts) ⇒ Data
Create a new instance
34 35 36 |
# File 'lib/vagrant_cloud/data.rb', line 34 def initialize(**opts) @data = opts end |
Instance Method Details
#[](k) ⇒ Object
Fetch value from data
42 43 44 |
# File 'lib/vagrant_cloud/data.rb', line 42 def [](k) @data.key?(k.to_sym) ? @data[k.to_sym] : Nil end |
#inspect ⇒ String
47 48 49 |
# File 'lib/vagrant_cloud/data.rb', line 47 def inspect "<#{self.class.name}:#{sprintf("%#x", object_id)}>" end |