Skip to content

xingwang/ruby-misc-code

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

ruby-misc-code

Just a couple notes for quick referencing in the future in case I forget.

  1. Use %Q to add double quotes around a string for cleaner looking strings that require double quotes.
puts %Q|{"message":"Malformed url #{image[:uri]}", "_id": "#{@test["_id"]}", "field_name": "#{image[:description]}"}|

A pretty good read up can be found here

  1. When including a class, the main class gets access to all the included class's methods. The included class also gets access to the main class's instance variables.
class First
  include Second
  def initialize
    @monkey = "wont do"
  end
end

class Second
  def what_about_the_monkey
    puts @monkey #prints out "wont do"
  end
end
  1. In Ruby, valid JSON requires double quotes unlike Javascript where the preferred way is with single quotes.

  2. In Ruby, the & does way too much. Good read found here

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published