Class: DIY::Namespace

Inherits:
Object
  • Object
show all
Defined in:
lib/diy.rb

Overview

:nodoc:#

Instance Method Summary collapse

Constructor Details

#initialize(str) ⇒ Namespace

Returns a new instance of Namespace.

Raises:



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

Instance Method Details

#build_classname(name) ⇒ Object



284
285
286
# File 'lib/diy.rb', line 284

def build_classname(name)
  [ @module_nest, Infl.camelize(name) ].flatten.join("::")
end