Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ The `ostruct` library comes pre-packaged with Ruby. No installation is necessary

## Usage

```
```ruby
require "ostruct"

person = OpenStruct.new
Expand All @@ -22,14 +22,14 @@ The `ostruct` library comes pre-packaged with Ruby. No installation is necessary

An OpenStruct employs a Hash internally to store the attributes and values and can even be initialized with one:

```
```ruby
australia = OpenStruct.new(:country => "Australia", :capital => "Canberra")
# => #<OpenStruct country="Australia", capital="Canberra">
```

Hash keys with spaces or characters that could normally not be used for method calls (e.g. <code>()[]*</code>) will not be immediately available on the OpenStruct object as a method for retrieval or assignment, but can still be reached through the Object#send method.

```
```ruby
measurements = OpenStruct.new("length (in inches)" => 24)
measurements.send("length (in inches)") # => 24

Expand All @@ -41,7 +41,7 @@ Hash keys with spaces or characters that could normally not be used for method c

Removing the presence of an attribute requires the execution of the delete_field method as setting the property value to +nil+ will not remove the attribute.

```
```ruby
first_pet = OpenStruct.new(:name => "Rowdy", :owner => "John Smith")
second_pet = OpenStruct.new(:name => "Rowdy")

Expand Down