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
| # Encoding: UTF-8 | |
| # Column-Separator: | | |
| # Record-Separator: auto | |
| # Name: items | |
| # Headers: true | |
| ID | Name | Price | Inventory | |
| 1 | Watch | 2.99$ | 50 | |
| 2 | Table | 119.99$ | 12 | |
| 3 | Chair | 49.99$ | 19 |
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
| # Same result for the same IBM437 character - whether it's utf-8 or IBM437 encoded at input | |
| JSON.parse(JSON.dump(["\u2561".encode('IBM437')])).first.unpack("U*") # => [9569] | |
| JSON.parse(JSON.dump(["\u2561"])).first.unpack("U*") # => [9569] |
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
| Encoding: UTF-8 | |
| Column-Separator: 7c | |
| Record-Separator: 0a | |
| Name: items | |
| Headers: true | |
| "ID" | "Name" | "Price" | "Inventory" | |
| 1 | "Watch" | 2.99 | 50 | |
| 2 | "Table" | 119.99 | 12 |
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 LayoutHelper | |
| ActionMapping = { | |
| 'create' => 'new', | |
| 'update' => 'edit', | |
| } | |
| private | |
| def rendered_action | |
| @_rendered_action ||= begin |
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 Enumerable | |
| def compacting | |
| return enum_for(__method__) unless block_given? | |
| result = [] | |
| each do |value| | |
| next if value.nil? | |
| result << value | |
| yield(value) |
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 class_call(*args, &block) | |
| self.class.__send__(caller_locations(1,1).first.label, *args, &block) | |
| end | |
| def class_method(name=caller_locations(1,1).first.label) | |
| self.class.method(name) | |
| end | |
| def class_send(name=caller_locations(1,1).first.label, *args, &block) | |
| self.class.__send__(name, *args, &block) | |
| 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 class_call(*args, &block) | |
| self.class.__send__(caller_locations(1,1).first.label, *args, &block) | |
| end | |
| end | |
| class Foo | |
| def self.bar | |
| "bar" | |
| 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 A | |
| X = 1 | |
| end | |
| module A | |
| class B | |
| def self.x | |
| X | |
| 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
| ## file a.rb | |
| module A | |
| X = 1 | |
| end | |
| ## file a/b.rb | |
| module A | |
| class B | |
| def self.x | |
| X |
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 | |
| def match_all(regex) | |
| if block_given? | |
| scan(regex) { yield $~ } | |
| else | |
| enum_for(:scan, regex).map { $~ } | |
| end | |
| end | |
| end |