Class: OpenStruct
- Inherits:
-
Object
- Object
- OpenStruct
- Defined in:
- lib/ostructfixed.rb
Direct Known Subclasses
Instance Method Summary collapse
-
#[](field) ⇒ Object
Get the field by its name, faster than #send and with dynamic field names more convenient.
-
#[]=(field, value) ⇒ Object
Assign a field by its name, faster than #send and with dynamic fields more convenient.
-
#__hash__ ⇒ Object
Get the internal hash-table.
-
#to_hash ⇒ Object
Get a copy of the table with the members.
Instance Method Details
#[](field) ⇒ Object
Get the field by its name, faster than #send and with dynamic field names more convenient.
16 17 18 |
# File 'lib/ostructfixed.rb', line 16 def [](field) @table[field.to_sym] end |
#[]=(field, value) ⇒ Object
Assign a field by its name, faster than #send and with dynamic fields more convenient
22 23 24 25 |
# File 'lib/ostructfixed.rb', line 22 def []=(field,value) new_ostruct_member(field) @table[field.to_sym] = value end |
#__hash__ ⇒ Object
Get the internal hash-table.
33 34 35 |
# File 'lib/ostructfixed.rb', line 33 def __hash__ @table end |
#to_hash ⇒ Object
Get a copy of the table with the members.
28 29 30 |
# File 'lib/ostructfixed.rb', line 28 def to_hash @table.dup end |