-1. Make Google spreadsheet accessble from anyone.
- Share button on the right above.
- Set "Anyone with the link can view"
-2. (Re)Publish automatically
- "File > publish to the Web"
| # In Ruby, unlike many programming languages, calling methods do not need to see the implementation of the method directly. It's enough if those implmentations can be seen when called (executed) | |
| # Note1: Ruby object can extend its functionality with extend. | |
| # Note2: a method given only to a single object is called a singleton method in Ruby. | |
| module Hello | |
| def hello | |
| puts "Hello" | |
| end | |
| end |
| ## Sailr script for knitr engine | |
| ## I mimicked the code for stan engine | |
| eng_sailr = function(options) { | |
| code = one_string(options$code) | |
| opts = options$engine.opts | |
| ## | |
| if (is.null(x <- options$output.var)) { | |
| warning("the option engine.opts$x is deprecated; use the chunk option output.var instead") | |
| x = opts$x |
| // Java has static and instance fields. | |
| // Java has static and instance methods. | |
| // Moreover, in code level, Java has static and instance contexts. | |
| // Static methods have static context. | |
| // Static field can be accessed in static context. | |
| // | |
| // Instance methods have instance context. | |
| // Instance field can be accessed in instance context. | |
| // Static field can also be accessed in instance context. // THIS IS AN IMPORTANT PART |
| # Class (Class object, eigenclass ) also has its own instance variable(class instance variable). | |
| # It can be accessed in static method. | |
| # By the way, the difference in practice btw class variable and class instance is as follows, | |
| # Class variable is shared by some related objects, say, its instances and inherited classes. | |
| # Class instance variable is an instance variable of only class object. | |
| # In code level, the difference is | |
| # class variable can be written anywhere | |
| # class instance variable can be written in class definition outside of method definitions or in static method definition. |
In JRuby, we can write Ruby code as if we are in real Ruby world. Moreover, From JRuby, most of the methods in Java class can be easily and seamlessly accessed!
One thing I have to keep in mind is that when we pass Ruby objects to Java method, how these objects are converted. And vice versa. (When Java objects are passed to Java methods, I don't have to take care about it. And also Ruby objects passed to Ruby methods.)
Most of the embedded Ruby libraries can be automatically converted to Java coresponding classes.
| # require "java" provides top-level functions like com, org, java, and javax. | |
| require "java" | |
| ############################### | |
| # Access Java class. (with package name (Ruby namespace)) | |
| ############################### | |
| java.lang.StringBuffer | |
| # In JRuby, this class is recognized as | |
| # Java::JavaLang::StringBuffer | |
| # The begining Java:: means |
| # This is a code for JRuby. | |
| # | |
| # Put the commons-math3-3.4.1.jar in the current code. | |
| # Run | |
| # $ jruby -J-cp commons-math3-3.4.1.jar TTESTStat.rb | |
| # | |
| require "java" | |
| module ACMStat |
| // Put the commons-math3-3.4.1.jar file in the same directory of this code. | |
| // Run : | |
| // $ javac -cp commons-math3-3.4.1.jar TTESTStat.java | |
| // $ java -cp .:commons-math3-3.4.1.jar TTESTStat | |
| // | |
| // When running "java", you have to be careful about "-cp option" having ".:" in its argument. | |
| // | |
| // "-cp" option clears previous CLASSPATH setting. | |
| // When running javac, TTESTStat.java means a file on filesystem (Not a java class yet. Still just a file at this point). | |
| // So ".:" is not required. |