Class: OpenStruct

Inherits:
Object
  • Object
show all
Defined in:
lib/ostructfixed.rb

Direct Known Subclasses

Templater::Variables

Instance Method Summary collapse

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_hashObject

Get a copy of the table with the members.



28
29
30
# File 'lib/ostructfixed.rb', line 28

def to_hash
	@table.dup
end