From 25e5af248636bbea39f39970159e413b8f4fdc8b Mon Sep 17 00:00:00 2001 From: Harry Yuan <33657734+harryuan65@users.noreply.github.com> Date: Sun, 10 Apr 2022 16:27:02 +0800 Subject: [PATCH] Update README.md Hello ! I just want to add `ruby` to markdown code blocks for cleaner look --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 7387b48..9c9769f 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ The `ostruct` library comes pre-packaged with Ruby. No installation is necessary ## Usage -``` +```ruby require "ostruct" person = OpenStruct.new @@ -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") # => # ``` Hash keys with spaces or characters that could normally not be used for method calls (e.g. ()[]*) 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 @@ -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")