Module2Class 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/module2class.rb +11 -0
- metadata +45 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0d6fc624245e68448d800a68f1d006fcb76bca40c276a093e6f9a20b7e3df181
|
4
|
+
data.tar.gz: 7847243ec4991cb801612280287c2da349dc67755572544681b2a506eee9c0c7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8ce94f44d1ab6580fe820cccf85884834054d5b206fd420272f2f10e2b77ff975123ddeb15daba052eb1265b7b68383b0d124b483659eecd450bfedb9668a714
|
7
|
+
data.tar.gz: 320602020ad5583b987c078a1b3b25bbf9bad496abab271bc91762a7449b33df82a4ac4f6690c95267b9f9d3213772999cbcc7eb954fae764dd63c84dae6dd38
|
data/lib/module2class.rb
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
class Module2Class
|
2
|
+
def self.convert(x)
|
3
|
+
(Object.const_get(x.name).instance_of?Class) ? var = Module.new : var = Class.new
|
4
|
+
arr=self.instance_methods(true)
|
5
|
+
(Object.const_get(x.name).instance_of?Class) ? (x.instance_methods(false).each{|meth| var.send(:define_method,meth,&x.new.method(meth))}) : var.include(x)
|
6
|
+
x.singleton_methods(false).each{|meth| var.send(:define_singleton_method,meth,&x.method(meth))}
|
7
|
+
x.constants.each{|const| var.const_set(const,x.const_get(const))}
|
8
|
+
Object.send(:remove_const,x.name)
|
9
|
+
Object.const_set(x.name,binding.local_variable_get(:var))
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: Module2Class
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Venkatesh Babu
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-02-18 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: "\tThis gem is used to convert a given single level Module to a Class
|
14
|
+
with \n\tsame name and with complete functionalities and vice versa.\n"
|
15
|
+
email: chitralavenky55@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- lib/module2class.rb
|
21
|
+
homepage: http://rubygems.org/gems/module2class
|
22
|
+
licenses:
|
23
|
+
- Nonstandard
|
24
|
+
metadata: {}
|
25
|
+
post_install_message:
|
26
|
+
rdoc_options: []
|
27
|
+
require_paths:
|
28
|
+
- lib
|
29
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
35
|
+
requirements:
|
36
|
+
- - ">="
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
requirements: []
|
40
|
+
rubyforge_project:
|
41
|
+
rubygems_version: 2.7.6
|
42
|
+
signing_key:
|
43
|
+
specification_version: 4
|
44
|
+
summary: Module to Class and Class to Module converter
|
45
|
+
test_files: []
|