This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tradução | |
-------- | |
Tem conhecimentos que conhecemos. São as coisas que nós sabemos que sabemos. | |
Tem conhecimentos que não conhecemos. Isso é, tem coisas que nós sabemos que não sabemos. | |
Mas tem também conhecimentos desconhecidos. Essas são as coisas que não sabemos que não sabemos. | |
original | |
-------- | |
There are known knowns. These are things we know that we know. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass | |
attr :name #this will create a getter for this property | |
attr :hair_color, true #the _true_ parameter will enable a setter for this property | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass | |
attr :name #this will create a getter for this property | |
attr_accessor :hair_color #this will create a getter and setter for this property | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass | |
attr :name #this will create a getter for this property | |
attr_accessor :hair_color #this will create a getter and setter for this property | |
attr_reader :age, :surname, :birthdate #this will create only getters for all these properties | |
attr_writer :listening, :talking #this will create only setters for all these properties | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MyClass | |
def complex_property | |
@my_complex_property | |
end | |
def complex_property= value | |
#complex logic | |
@my_complex_property = revamped_value | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo gem install rack-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ touch test.rb | |
$ echo "require 'rack/test'" >> test.rb | |
$ ruby test.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ gem which rack | |
/var/lib/gems/1.9.1/gems/rack-1.2.1/lib/rack.rb | |
$ gem which rack/test | |
/usr/lib/ruby/gems/1.9.1/gems/rack-test-0.5.4/lib/rack/test.rb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo ln -s /usr/lib/ruby/gems/1.9.1/gems/rack-test-0.5.4/ /var/lib/gems/1.9.1/gems/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# odd difference between Ruby's AND comparison operators: '&&' and 'and' | |
## | |
# with '&&' it will throw an error expecting 'end' after params.include? | |
if request.post? && request.params.include? 'post_param' then | |
end | |
# with 'and' it will work fine and you'll call the day for a beer | |
if request.post? and request.params.include? 'post_param' then |