Class: VagrantCloud::Data

Inherits:
Object
  • Object
show all
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

Immutable

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

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

Parameters:

  • k (String, Symbol)

    Name of value

Returns:

  • (Object)


42
43
44
# File 'lib/vagrant_cloud/data.rb', line 42

def [](k)
  @data.key?(k.to_sym) ? @data[k.to_sym] : Nil
end

#inspectString

Returns:

  • (String)


47
48
49
# File 'lib/vagrant_cloud/data.rb', line 47

def inspect
  "<#{self.class.name}:#{sprintf("%#x", object_id)}>"
end