Class: VER::Register
Direct Known Subclasses
Defined Under Namespace
Classes: Clipboard
Constant Summary collapse
- REGISTERS =
{}
Constants inherited from Struct
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
- .[](name) ⇒ Object
-
.[]=(name, value) ⇒ Object
Assign given value to register of given name.
- .each(&block) ⇒ Object
- .fetch(name) ⇒ Object
Instance Method Summary collapse
Methods inherited from Struct
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
2 3 4 |
# File 'lib/ver/register.rb', line 2 def name @name end |
#value ⇒ Object
Returns the value of attribute 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
#inspect ⇒ Object
23 24 25 |
# File 'lib/ver/register.rb', line 23 def inspect "#<VER::Register name=%p, value=%p>" % [name, value] end |