Class: Citero::Base
- Inherits:
-
Object
- Object
- Citero::Base
- Defined in:
- lib/citero-jruby/base.rb
Overview
The Base class is the true wrapper for citation
Constant Summary collapse
- JavaCitero =
Import of important java files.
Java::EduNyuLibraryCitero::Citero
Instance Method Summary collapse
-
#csf ⇒ Object
Returns a CSF object.
-
#initialize(data) ⇒ Base
constructor
The constructor, takes input data taken from the parent module and creates an instance of the Citero java object.
-
#method_missing(meth, *args, &block) ⇒ Object
The method_missing override checks to see if the called method can be evaluated to a method name and parameter, then stores it and calls it if it can.
-
#respond_to?(meth, include_private = false) ⇒ Boolean
Returns true if the method can be evaluated to a method name and parameter.
Constructor Details
#initialize(data) ⇒ Base
The constructor, takes input data taken from the parent module and creates an instance of the Citero java object. Returns itself for builder patttern.
44 45 46 47 |
# File 'lib/citero-jruby/base.rb', line 44 def initialize data @citero = JavaCitero::map(data) self 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 method name and parameter, then stores it and calls it if it can. For example, to_csf or from_pnx. pnx_to will not work.
95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/citero-jruby/base.rb', line 95 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 send directionize(meth).to_sym, formatize(meth) end # calls the method send meth, *args, &block else super end end |
Instance Method Details
#csf ⇒ Object
Returns a CSF object
84 85 86 87 88 89 |
# File 'lib/citero-jruby/base.rb', line 84 def csf CSF::new(self.to_csf) # Rescue all exceptions, but mostly likeley a problem with the source format. rescue Exception => e raise ArgumentError, "Missing a source format. Use from_[format] first." end |
#respond_to?(meth, include_private = false) ⇒ Boolean
Returns true if the method can be evaluated to a method name and parameter.
112 113 114 115 116 117 118 |
# File 'lib/citero-jruby/base.rb', line 112 def respond_to? meth, include_private=false if(matches? meth) return true else super end end |