Class: DIY::Namespace
- Inherits:
-
Object
- Object
- DIY::Namespace
- Defined in:
- lib/diy.rb
Overview
:nodoc:#
Instance Method Summary collapse
- #build_classname(name) ⇒ Object
-
#initialize(str) ⇒ Namespace
constructor
A new instance of Namespace.
Constructor Details
#initialize(str) ⇒ Namespace
Returns a new instance of Namespace.
269 270 271 272 273 274 275 276 277 278 279 280 281 282 |
# File 'lib/diy.rb', line 269 def initialize(str) # 'using_namespace Animal Reptile' parts = str.split(/\s+/) raise "Namespace definitions must begin with 'using_namespace'" unless parts[0] == 'using_namespace' parts.shift if parts.length > 0 and parts[0] =~ /::/ parts = parts[0].split(/::/) end raise NamespaceError, "Namespace needs to indicate a module" if parts.empty? @module_nest = parts end |