I have an ActiveRecord result of a find operation: tasks_records = TaskStoreStatus.find( :all, :select => "task_id, store_name, store_region", :conditions => ["task_status = ? and store_id = ?", "f", store_id] ) Now I want to convert this results into an array of hashes like this: [0] -> { :task_d => 10, :store_name=> "Koramanagala", :store_region=> "India" } [1] -> { :task_d => 10, :store_name=>
Is there any ready function which converts camel case Strings into underscore separated string? I want something like this: "CamelCaseString".to_underscore to return "camel_case_string". ...
文字列が"1"とか"123"とか数値を表すものかどうかを調べたい時には以下のやり方で調べられます。 # Integer()で変換できれば数値、例外発生したら違う def integer_string?(str) Integer(str) true rescue ArgumentError false end # Float()で変換できれば数値、例外発生したら違う def float_string?(str) Float(str) true rescue ArgumentError false end ちなみに結果は以下のようになります。 str = "あいうえお" str2 = "123" str3 = "3.14" str4 = "12345" # 普通の文字列 integer_string?(str) #=> false # 数値の文字列 integer_string?(str2)
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く