Module: Mario::Tools
- Defined in:
- lib/mario/tools.rb
Constant Summary collapse
- @@class_method_blocks =
{}
- @@defer_method_definition =
false
Class Method Summary collapse
- .defer_method_definition ⇒ Object
- .defer_method_definition! ⇒ Object
- .defer_method_definition=(val) ⇒ Object
Instance Method Summary collapse
- #define_platform_methods! ⇒ Object
- #platform(name, method = nil, &block) ⇒ Object
- #platform_value_map(map = {}) ⇒ Object
Class Method Details
.defer_method_definition ⇒ Object
6 7 8 |
# File 'lib/mario/tools.rb', line 6 def defer_method_definition @@defer_method_definition end |
.defer_method_definition! ⇒ Object
14 15 16 |
# File 'lib/mario/tools.rb', line 14 def defer_method_definition! @@defer_method_definition=true end |
.defer_method_definition=(val) ⇒ Object
10 11 12 |
# File 'lib/mario/tools.rb', line 10 def defer_method_definition=(val) @@defer_method_definition=val end |
Instance Method Details
#define_platform_methods! ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/mario/tools.rb', line 32 def define_platform_methods! @@class_method_blocks[self].each do |name, value| if Platform.check_symbol(name) if value.is_a?(Proc) self.class_eval &value else define_method value.first, &value.last end end end end |
#platform(name, method = nil, &block) ⇒ Object
20 21 22 23 24 |
# File 'lib/mario/tools.rb', line 20 def platform(name, method=nil, &block) @@class_method_blocks[self] ||= {} @@class_method_blocks[self][name] = method ? [ method , block ] : block define_platform_methods! unless defer_method_definition end |
#platform_value_map(map = {}) ⇒ Object
26 27 28 29 30 |
# File 'lib/mario/tools.rb', line 26 def platform_value_map(map={}) map.each do |key, value| return value if Platform.check_symbol(key) end end |