This file contains hidden or 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 Person | |
| def say_hi | |
| puts "Hi, this is Ruby!" | |
| end | |
| end | |
| john = Person.new | |
| robin = Person.new | |
| john.say_hi # => Hi, this is Ruby! |
This file contains hidden or 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
| module A | |
| def say_hi(a,b,c) | |
| puts "Hi, from [A] module. Numbers - #{a} #{b} #{c}" | |
| end | |
| end | |
| class B | |
| include A | |
| def say_hi(a,b,c) |
This file contains hidden or 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
| module A | |
| def say_hi(a,b,c) | |
| puts "Hi, from [A] module. Numbers - #{a} #{b} #{c}" | |
| end | |
| end | |
| class B | |
| include A | |
| def say_hi(a,b,c) |
This file contains hidden or 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
| module A | |
| def say_hi(a,b,c) | |
| puts "Hi, from [A] module. Numbers - #{a} #{b} #{c}" | |
| end | |
| end | |
| class B | |
| include A | |
| def say_hi(a,b,c) |
This file contains hidden or 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
| module A | |
| def say_hi(a,b,c) | |
| puts "Hi, from [A] module. Numbers - #{a} #{b} #{c}" | |
| end | |
| end | |
| class B | |
| include A | |
| def say_hi(a,b,c) |
This file contains hidden or 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
| Person = Class.new do | |
| #instance method | |
| def say_hi | |
| puts "Hi, Do you like Ruby?" | |
| end | |
| end | |
| Person.new.say_hi |
This file contains hidden or 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
| Person = Class.new | |
| module PersonInstanceMethods | |
| def say_hi | |
| puts "Hi, Do you like Ruby?" | |
| end | |
| end | |
| Person.send(:include, PersonInstanceMethods) | |
| john = Person.new |
This file contains hidden or 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 Person | |
| def say_hi | |
| puts "Hi, Do you like Ruby?" | |
| end | |
| end | |
| john = Person.new | |
| john.say_hi | |
This file contains hidden or 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
| > require "rubygems" | |
| => true | |
| > require "goshortener" | |
| => true | |
| > go = GoShortener.new("yourapikeyfromgoogle") | |
| => #<GoShortener:0x10056e6a8 @base_url="https://www.googleapis.com/urlshortener/v1/url", @api_key="yourapikeyfromgoogle"> | |
| > go.shorten("http://github.com/luckydev") | |
| => "http://goo.gl/TCZHi" | |
| > go.lengthen("http://goo.gl/TCZHi") | |
| => "http://github.com/luckydev" |
This file contains hidden or 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
| Event.observe(window,'load',function(){ | |
| $('content').observe('click',function(event){ | |
| var element = event.findElement('a.item'); | |
| if(element.tagName == 'A'){ | |
| alert("got you....."); | |
| } | |
| }); | |
| }); |