Class: VER::Register

Inherits:
Struct
  • Object
show all
Defined in:
lib/ver/register.rb

Direct Known Subclasses

Clipboard

Defined Under Namespace

Classes: Clipboard

Constant Summary collapse

REGISTERS =
{}

Constants inherited from Struct

Struct::CACHE

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Struct

new

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



2
3
4
# File 'lib/ver/register.rb', line 2

def name
  @name
end

#valueObject

Returns the value of attribute value

Returns:

  • (Object)

    the current value of value



2
3
4
# File 'lib/ver/register.rb', line 2

def value
  @value
end

Class Method Details

.[](name) ⇒ Object



5
6
7
8
# File 'lib/ver/register.rb', line 5

def self.[](name)
  name = name.to_str
  REGISTERS[name] ||= new(name)
end

.[]=(name, value) ⇒ Object

Assign given value to register of given name



11
12
13
# File 'lib/ver/register.rb', line 11

def self.[]=(name, value)
  self[name].value = value
end

.each(&block) ⇒ Object



15
16
17
# File 'lib/ver/register.rb', line 15

def self.each(&block)
  REGISTERS.values.each(&block)
end

.fetch(name) ⇒ Object



19
20
21
# File 'lib/ver/register.rb', line 19

def self.fetch(name)
  REGISTERS.fetch(name.to_str)
end

Instance Method Details

#inspectObject



23
24
25
# File 'lib/ver/register.rb', line 23

def inspect
  "#<VER::Register name=%p, value=%p>" % [name, value]
end