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
| # Create a file my_modeule.rb | |
| # Include it in your application load path (Standard: app/lib ) | |
| # FILE CONTENTS BEGIN HERE | |
| module MyModule | |
| def self.included(base) | |
| base.extend ClassMethods | |
| class << base | |
| attr_accessor :class_variable | |
| end |
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 FooModule | |
| def say_hello | |
| "Hello!" | |
| end | |
| end | |
| class FooClass | |
| include FooModule | |
| end |
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
| 10.3 - 10 | |
| # 0.300000000000001 | |
| a = 10.3 - 10 | |
| # 0.300000000000001 | |
| b = 0.300000000000000 | |
| # 0.300000000000000 | |
| a == b | |
| # false | |
| (a + 10) == (b + 10) | |
| # true |
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
| def self.auto_link_content(content) | |
| # Splits all HTML tags, except <a></a> tags. Keeps <a></a> tags as whole | |
| # so that we don't accidentally link already linked Keywords | |
| word_groups = content.split(/(<a[^>]*>.+?<\/a>|<\/?[^>]*>|[.]|,|['"]+)/i) | |
| word_groups.collect! do |words| | |
| (!words.match(/<\/?[^>]*>|[.]+|,+/) && words.match(/([a-zA-Z]+)/)) ? link_it(words) : words | |
| end | |
| word_groups.join | |
| end |
NewerOlder