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 Foo | |
| # @overload foo | |
| # @return [FooObject] | |
| # @overload foo=(value) | |
| # @param [String] value something with value | |
| # @return [void] | |
| attr_accessor :foo | |
| # (don't document here) | |
| def foo=(val) |
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 Foo | |
| def apply(meth) | |
| items.each do |v| | |
| v.send(meth) | |
| end | |
| end | |
| 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
| class String | |
| # Splits text into tokens the way a shell would, handling quoted | |
| # text as a single token. Use '\"' and "\'" to escape quotes and | |
| # '\\' to escape a backslash. | |
| # | |
| # @return [Array] an array representing the tokens | |
| def shell_split | |
| out = [""] | |
| state = :none | |
| escape_next = false |
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 'rake/gempackagetask' | |
| class Gem::Specification | |
| attribute :wiki | |
| attribute :bugtracker | |
| end | |
| SPEC = Gem::Specification.new do |s| | |
| s.name = "gemspec-test" | |
| s.summary = "Testing a gemspec" |
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 MYCLASS(klass, &block) | |
| eval "class #{klass}; end" | |
| eval(klass).instance_eval(&block) | |
| end | |
| def MYDEFINE(meth, &proc) | |
| define_method(meth, &proc) | |
| end | |
| #### Your new DSL: #### |
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
| --title "Refinery CMS" | |
| lib/**/*.rb' | |
| app/**/*.rb | |
| db/seeds.rb | |
| config/preinitializer.rb | |
| vendor/plugins/images/**/*.rb | |
| vendor/plugins/authentication/**/*.rb | |
| vendor/plugins/dashboard/**/*.rb | |
| vendor/plugins/inquiries/**/*.rb | |
| vendor/plugins/news/**/*.rb |
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
| get '/docs/:project/*/?' do | |
| setup_project | |
| setup_page | |
| opts = { | |
| serialize: false, | |
| serializer: serializer, | |
| project: project, | |
| project_path: project_path, | |
| type: :layout |
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 Object | |
| def self.method_added(name) | |
| const_set(:InstanceMethods, Module.new) unless defined?(self::InstanceMethods) | |
| meth = instance_method(name).bind(self.allocate) | |
| self::InstanceMethods.send(:define_method, name, &meth) | |
| remove_method(name) | |
| include self::InstanceMethods | |
| end | |
| 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
| class Object | |
| def self.method_added(name) | |
| return if name == :initialize | |
| const_set(:InstanceMethods, Module.new) unless defined?(self::InstanceMethods) | |
| self::InstanceMethods.send(:define_method, name, &instance_method(name).bind(self.allocate)) | |
| remove_method(name) | |
| include self::InstanceMethods | |
| end | |
| 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
| def uniq_min(list) | |
| shortest, another = nil, nil | |
| list.each do |obj| | |
| another = obj if shortest && obj.length == shortest.length | |
| shortest, another = obj, nil if !shortest || obj.length < shortest.length | |
| end | |
| another ? false : shortest | |
| end | |