原创 [Ruby筆記]18.Ruby 繼承 Inheritance 與 .superclass

Inheritance < 打開irb ,定義一個Super類 PS C:\Users\Administrator> irb --simple-prompt >> class Super >> def say_hel

原创 [Ruby筆記]23.Ruby self “main class module instance”

self ! test_self.rb puts "Top Level" puts "self is #{self}" # self is main class C puts "Class definition b

原创 [Ruby筆記]7.ruby -e ' " 單引號、雙引號對比

environment Windows PowerShell ruby -e 使用ruby -e "..."可以在命令行直接運行腳本 PS C:\Users\Administrator\RubyCode> ruby -e "

原创 [Ruby筆記]15.@instance_variable 以及 糖“在方法名中可使用=”

代碼 Sugar Class 寫一個Sugar類,方法 price=(amount) 可以設置價格,方法price 可以獲取價格 : class Sugar def price=(amount) @pri

原创 [Ruby筆記]9.Ruby文檔工具 ri ruby-doc Windows CMD.exe Powershell

在Windows上安裝ruby-doc ri 工具 安裝步驟 Ruby的命令行文檔工具ri ,一般安裝步驟[1] 1.在終端運行 gem install rdoc-data 安裝 2.然後需要生成 ri 數據,在終端運行

原创 [Ruby筆記]14.Ruby local_variable

Ruby local_variable 可用命名格式 a _a name first_name hello48 user_ID _ Ruby如何區分local_variable /keyword/ method call I

原创 [Ruby筆記]6. Ruby load require 使用對比

Example files 當前目錄下有兩個文件 loaddemo.rb 以及 loadee.rb PS C:\Users\Administrator\RubyCode> ls Mode Last

原创 [Ruby筆記]21.Ruby public_method_defined? 以及 method_missing

public_method_defined? 在A類中定義了一個hello方法,使用public_method_defined?就可以判斷是不是存在 : PS C:\Users\Administrator\Rubycode>

原创 [Ruby筆記]20.Ruby super initialize class

code in file abc.rb class SuperABC def initialize @a = 1 @b = 2 @c = 3 end end cla

原创 [Ruby筆記]11.Ruby == .equal? object .object_id .respond_to? .send()

Ruby object .object_id .respond_to? .send() obj.rb source code .object_id 可以獲取對象id,該id唯一確認一個對象; request = gets.cho

原创 [Ruby筆記]19.Ruby 2.0+ prepend 與 include

code 創建一個win.rb 文件: PS C:\Users\Administrator\RubyCode> ls -a--- 2016/6/3 16:52 142 win.rb 使用pr

原创 [讀書筆記]2.標準誤差 標準差 信度 實例計算說明

概念名詞 信度理論 Observed Score = True Score + Error Score 觀測分數 = 真分數 + 誤差分數 舉例說明 如果你去參加一場考試,你實際最後得到的分數就叫做 Observed S

原创 [Ruby筆記]22.Ruby :: namespace 以及 instance method 與class method

:: namespace 在module裏面放了一個class,要實例化這個class,需要用M::C.new , module M 起到了namespace的作用,從視覺上大大加強代碼的可讀性: PS C:\Users\Admi

原创 [Ruby筆記]24.Ruby全局變量 $global_variable

$global_variable $符號是全局變量的標識; time << "#{$minute} : " if $minute ,如果minute 非空就加入到time 之中; 可以看到,給$變量賦值的時候都是不帶t.xxx

原创 [Ruby筆記]16.Ruby 判斷數字 .is_a?(Numeric) .to_i

使用.is_a?(Numeric) PS C:\Users\Administrator\RubyCode> irb --simple-prompt >> 100.is_a?(Numeric) => true 使用.to_i num