Module: JavaHead

Defined in:
lib/java_head.rb,
lib/java_head/class.rb,
lib/java_head/package.rb,
lib/java_head/version.rb,
lib/java_head/classpath.rb

Overview

The namespace for the classes

Defined Under Namespace

Modules: Exceptions Classes: Class, Package

Constant Summary collapse

VERSION =
"1.1.2"
CLASSPATH =

An array of Pathnames representing the CLASSPATH environment variable Defaults to the current values of the $CLASSPATH environment variable

[Pathname.new('.')]

Class Method Summary collapse

Class Method Details

.class(name = nil) ⇒ JavaHead::Class

Returns the class with no arguments Returns a new class with the given name if an argument is passed

Parameters:

  • name (String) (defaults to: nil)

    the name of the class to initialize

Returns:



27
28
29
30
# File 'lib/java_head.rb', line 27

def class(name = nil)
  return super() if name.eql? nil
  JavaHead::Class.new(name)
end

.const_missing(const_name) ⇒ Regexp, ...

Try to load the file const_name if the constant cannot be found

Parameters:

Returns:

  • (Regexp, Array, Class)

    the value of the constant const_name in the namespace of JavaHead



52
53
54
55
56
57
# File 'lib/java_head.rb', line 52

def const_missing(const_name)
  require "#{__dir__}/java_head/#{const_name.to_s.downcase}.rb"
  return const_get const_name
rescue LoadError
  super
end

.member(name) ⇒ JavaHead::Package, JavaHead::Class Also known as: >

Creates either a class or a package depending on the format of the given string

Parameters:

  • name (String)

    the name of the child element

Returns:



37
38
39
40
41
42
43
# File 'lib/java_head.rb', line 37

def member(name)
  if name.match JavaHead::Class::FORMAT
    self.class(name)
  else
    package(name)
  end
end

.package(name) ⇒ JavaHead::Package

Find a package using Package.get

Parameters:

  • name (String)

    the name of the package to be found

Returns:



18
19
20
# File 'lib/java_head.rb', line 18

def package(name)
  JavaHead::Package.get(name)
end