Class: Citero::CSF

Inherits:
Object
  • Object
show all
Defined in:
lib/citero-jruby/CSF.rb

Overview

CSF class, used to interact directly with available metadata.

Constant Summary collapse

CSF =

CSF object from Citero that is to be used

Java::EduNyuLibraryCitero::CSF

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ CSF

Initialize the CSF object with data



14
15
16
# File 'lib/citero-jruby/CSF.rb', line 14

def initialize data
  @csf = CSF::new(data)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object

The method_missing override checks to see if the called method can be evaluated to a key, then stores it and calls it if it can. For example, .itemType or .authors.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/citero-jruby/CSF.rb', line 21

def method_missing(meth, *args, &block)
  # Check to see if it can be evaluated
  if(matches? meth)
    #Defines the method and caches it to the class
    self.class.send(:define_method, meth) do
      # Splits the method and parameter. See formatize and directionize
      @csf::config()::getStringArray(meth.to_s.to_java_name).to_a
    end
    # calls the method
    send meth, *args, &block
  else
    super
  end
end

Instance Method Details

#keysObject

A list of keys that is available in this properties configuration



53
54
55
# File 'lib/citero-jruby/CSF.rb', line 53

def keys
  @keys ||= Array.new(@csf::config()::getKeys.collect {|key| key.to_ruby_name})
end

#respond_to?(meth, include_private = false) ⇒ Boolean

Returns true if the method can be evaluated to a key

Returns:

  • (Boolean)


37
38
39
40
41
42
43
# File 'lib/citero-jruby/CSF.rb', line 37

def respond_to? meth, include_private=false
  if(matches? meth)
    return true
  else
    super
  end
end