Class: Package
- Inherits:
-
Module
- Object
- Module
- Package
- Defined in:
- lib/package.rb
Defined Under Namespace
Modules: KernelMethods
Instance Attribute Summary collapse
-
#name ⇒ Object
(also: #to_s)
readonly
Returns the value of attribute name.
Class Method Summary collapse
- .[](key) ⇒ Object
- .[]=(key, value) ⇒ Object
-
.delete(ns) ⇒ Object
rubocop:enable Naming/MemoizedInstanceVariableName.
-
.loaded ⇒ Object
rubocop:disable Naming/MemoizedInstanceVariableName.
- .new(file) ⇒ Object
- .path ⇒ Object
- .reload! ⇒ Object
Instance Method Summary collapse
-
#initialize(file) ⇒ Package
constructor
A new instance of Package.
- #inspect ⇒ Object
- #load(file, wrap = false) ⇒ Object
Constructor Details
#initialize(file) ⇒ Package
Returns a new instance of Package.
113 114 115 116 117 |
# File 'lib/package.rb', line 113 def initialize(file) @source_file = file @name = KernelMethods.ns_from_filename(file) load_in_module(file) end |
Instance Attribute Details
#name ⇒ Object (readonly) Also known as: to_s
Returns the value of attribute name.
119 120 121 |
# File 'lib/package.rb', line 119 def name @name end |
Class Method Details
.[](key) ⇒ Object
86 87 88 |
# File 'lib/package.rb', line 86 def [](key) loaded[key] end |
.[]=(key, value) ⇒ Object
90 91 92 |
# File 'lib/package.rb', line 90 def []=(key, value) loaded[key] = value end |
.delete(ns) ⇒ Object
rubocop:enable Naming/MemoizedInstanceVariableName
100 101 102 |
# File 'lib/package.rb', line 100 def delete(ns) @store.delete(ns_to_filename(ns)) end |
.loaded ⇒ Object
rubocop:disable Naming/MemoizedInstanceVariableName
95 96 97 |
# File 'lib/package.rb', line 95 def loaded @store ||= {} end |
.new(file) ⇒ Object
81 82 83 84 |
# File 'lib/package.rb', line 81 def new(file) file = KernelMethods.ns_to_filename(file) self[file] ||= super(file) end |
.path ⇒ Object
108 109 110 |
# File 'lib/package.rb', line 108 def path $LOAD_PATH end |
.reload! ⇒ Object
104 105 106 |
# File 'lib/package.rb', line 104 def reload! @store = {} end |
Instance Method Details
#inspect ⇒ Object
128 129 130 |
# File 'lib/package.rb', line 128 def inspect format("#<#{self.class.name}(#{name}):0x%014x>", object_id) end |
#load(file, wrap = false) ⇒ Object
122 123 124 125 126 |
# File 'lib/package.rb', line 122 def load(file, wrap = false) wrap ? super : load_in_module(File.join(dir, file)) rescue Errno::ENOENT super end |