æ³ä»¤ããã¹ããããRubyã®æ£è¦è¡¨ç¾ãç¨ãã¦åæ¡ã®è¡¨é¡ãæ½åºãã 第ä¸æ¡ï¼å½å ç¯ ç¬¬äºæ¡ï¼ãã¹ã¦ã®è ã®å½å¤ç¯ ã»ã» ã®ããã«è¡¨ç¤ºããããã°ã©ã ã§ãã æ£è¦è¡¨ç¾ã®å¨åãããåããã¨æãã¾ãã 注ï¼è足ã§ãããscan() do .. end ã¯ãæ£è¦è¡¨ç¾ã®ã°ã«ã¼ãã«ãâ¦
ç¥èãã¾ã¨ãããã£ãã®ã§ãèãã¦ã¿ã¾ããã Rubyã§ã®æ£è¦è¡¨ç¾ã¯ã=~æ¼ç®åã§ããããããã©ããå¤å®ããããæååã«å¯¾ãã¦sub(), gsub(), scan()ãªã©ãå¼ã³åºãã¦ç¨ãã¾ãã å¾è ã«ã¤ãã¦ã¯ã第ä¸å¼æ°ã«æ£è¦è¡¨ç¾ãæå®ãã¾ãã第äºå¼æ°ã¯ãç½®æããã¹ãã§â¦
Rakeã¯Rubyãã«ããã¼ã«ã§ãMakefileã®Rubyçã§ãã ããããã°ã©ã ãå¥ã®ããã°ã©ã ã®å¾ã«å®è¡ãããã¨ãã£ããé åºãå¶å¾¡ãããå ´åãããããã°ã©ã ãå¥ã®ããã°ã©ã ã®çæãã¡ã¤ã«ã®åå¨ãåæã¨ããå ´åãªã©ãç°ãªãã¿ã¹ã¯ãã¤ãªãåããã¦æ©è½ããããâ¦
ããã³ã³ãã¥ã¼ã¿ã¼ã©ã¸ãªãè´ãã¦ãã¦(40æéLispãåå¼·ãããä¿¡è ã«ãªããï¼)ãLispé¢ç½ããã ãªã¨æã£ããã®ã®ãéãè¨èªãä»ããããæ°åã¯ç¡ãã®ã§ãåããã使ã£ã¦ããRubyã¨ã®æ¯è¼ã§ããããèãã¦ã¿ã¾ããã é¢ç½ããã»ã»ã ããªãåã«åå¼·ãã¦ã¿ãâ¦
DSLã®ä»æ§ãè¨è¿°ããè¨æ³ã§ããæ¡å¼µããã«ã¹ã»ãã¦ã¢è¨æ³ï¼EBNFï¼ã¨ãRubyã§å®éã«ãã®ä»æ§ãå®è£ ããæ¹æ³ã«ã¤ãã¦èãã¦ã¿ã¾ããã è¨èªä»æ§ã®æ§æè¦ç´ ã¨ãã¦ï¼çµç«¯è¨å· (Terminal symbols)ãéçµç«¯è¨å· (Non-terminal symbols)ãå°åºè¨å· (::=):ãé¸æ (|)â¦
èãã¦ã¿ã¾ããã é·ãæéã®ãããå¦çããé²è¡è¡¨ç¤ºããã¤ã¤ã¡ã¤ã³ã¹ã¬ãããå®è¡ãç¶ãããããªå ´é¢ãæ³å®ãã¦ãã¾ãã é²è¡è¡¨ç¤ºãããããã«ã¯ãæéã®æããã¹ã¬ããã§æ´æ°ããå¤ãã¡ã¤ã³ã¹ã¬ããçããåç §ããå¿ è¦ãããã¾ãã ãã®ããã«ã¯ãã¹ã¬ããâ¦
ã¦ã¼ã¶ã¼å´ããã®å ¥åãç°¡æããã°ã©ãã³ã°è¨èªã¿ããã«ãããã¨æããã¨ããã¾ã«ãã£ãã®ã§ãDSLã®ä½ææ¹æ³ãèãã¦ã¿ã¾ããã Rubyã®å ´åã¯ãç¹å®ã®ãªãã¸ã§ã¯ããã¬ã·ã¼ãã¼ã¨ãã¤ã¤ããã®ãªãã¸ã§ã¯ãã®ã³ã³ããã¹ãã§ãããã¯å ã®ã³ã¼ããå®è¡ãããinsâ¦
èãã¦ã¿ã¾ããã RSpecã§ãMockãªãã¸ã§ã¯ããç¨ãããã¹ããã§ããã®ã§ããããï¼ Userã¯ã©ã¹ã®ããã«ãªãã¸ã§ã¯ãã«ãè¤æ°ã®æ¯ãèããå®ç¾©ããã«ã¯ã©ãããã°è¯ãã§ããï¼ ããã«ã«å®ç¾©ã§ããæ¯ãèãã«ã¤ãã¦ãã¾ã¨ãã¦ããã ãã¾ãããï¼ ããã«ã渡ãâ¦
Matcherã¯ãexpect(v).to eq(3)ã®ããã«ãvã®å¤ãæå¾ éããã示ãæä½ã®eq(3)ã®é¨åã®ãã¨ã§ãã ï½ãããå¤ã«çãããã以ä¸ãã以ä¸ããæååãªãæ£è¦è¡¨ç¾ã«ãã¦ã¯ã¾ãããé åãããã·ã¥ãªãããå¤ããã¼ãå«ãããexpectã®å¼æ°ããããã¯ãªãæå¾ ããâ¦
RSpecãç¨ãã¦ããã¹ãé§åéçº(TDD)ãè¡ãæ¹æ³ãChatGPTã«èãã¾ããã åãã¹ãã±ã¼ã¹ã§ç¨ãããããã£ã¼ã«ã¤ãã¦ã¯ãæ©ä¼ãæ¹ãã¦èããã¨æãã¾ãã RSpecã«ã¤ãã¦æãã¦ãã ããã contextã®ä½¿ç¨ä¾ãè¦ããã§ãã ä¸ã®ä¾ã§ã¯ãdescribeã®å¼æ°ã«ã¯ã©ã¹ã®â¦
RubyXLã§Excelãæä½ããéã®Excelã®ã¹ã¿ã¤ã«æ å ±ã®ä¿æã®ããæ¹ãå©ç¨æ¹æ³ã«ã¤ãã¦è©³ããèãã¾ããã ææ¸ã®å®¹éç¯ç´ã®ããã«ãã¹ã¿ã¤ã«æ å ±ãé層çã«ãå¤ã¨ã¯å¥ã«ç®¡çããã¦ãããã¨ãåããã¾ããããã®åãå®éãã¹ã¿ã¤ã«ã追å ãããå¤æ´ãããã¯ããâ¦
使ããã¨æã£ãã¨ãã«ãã¤ãå®ç¾©ã®ä»æ¹ãå¿ãã¦ãã¾ãã®ã§ãæ°ã«ãªã£ã¦ãããã¨ãåããã¦èãã¦ã¿ã¾ããã Rubyã®Structã«ã¤ãã¦æãã¦ãã ããã Kotlinã§data classã使ãæèã§ä½¿ã£ã¦ãè¯ãã§ããï¼ Rubyã§ãã¼ã¿ã¯ã©ã¹ã«é¡ä¼¼ã®ã¯ã©ã¹ããªãã¸ã§ã¯ã使ãâ¦
Rubyã¯ãæ¨æºã¯ã©ã¹ã«ã¦ã¼ã¶ã¼å®ç¾©ã®ã¡ã½ãããå ãããã¨ãç°¡åã«åºæ¥ã¾ãããä¸é½åãå¤ãããªã®ã§ä»£æ¿çãèãã¦ã¿ã¾ããã ãã³ã¬ã¼ã¿ã¼ãã¿ã¼ã³ãç¨ããæ¹æ³ã¨ãRuby2.0以éã§è¿½å ãããã¨ãã'Refinement'ã使ãæ¹æ³ãè¯ãããã§ãã æ¨æºã©ã¤ãã©ãªã®â¦
Rubyã§Excelææ¸ãç·¨éããã«ã¯ãRubyXLã使ãããã§ãã ãã©ã³ãã®ç¨®é¡ããµã¤ãºãè²ãã»ã«ã®å¢çç·ãèæ¯è²ãªã©ã®ãã©ã¼ãããè¨å®ã¨ãã£ãã¹ã¿ã¤ã«æ å ±ã¯ãExcelãã¡ã¤ã«å ã®å¥ã®ãã¼ãã«ã«ç®¡çããã¦ããããã§ãããªã®ã§ãæ¢åã®ã·ã¼ãããã¹ã¿ã¤ã«ãã³â¦
Sequelã®åºæ¬çãªä½¿ãæ¹ã«ã¤ãã¦ãèãã¦ã¿ã¾ããã Rubyã®ORMã§ããSequelãéãã¦SQLiteãã¼ã¿ãã¼ã¹ãå©ç¨ããæ¹æ³ãæãã¦ãã ããã sqlite3ã¯å¥éã¤ã³ã¹ãã¼ã«ããå¿ è¦ãããã®ã§ããï¼ sqlite3 my_database.db ".quit"ã®ã³ãã³ãããgemã®ã¤ã³ã¹ãã¼â¦
Ruby on Railsã®AntiveRecordã¿ãããªORMããæ¥å¸¸çãªç¨éã§ã使ãããã¨æããChatGPTã«èãã¦ã¿ã¾ããã Sequelãè¯ãããã Ruby on Railsã®ActiveRecordã£ã¦ãRuby on Railsã®ç°å¢ä»¥å¤ã§ã使ããã®ã§ããï¼ Rubyã§ä½¿ããORMã©ã¤ãã©ãªã§å®çªã®ãã®ã¯ä»ã«â¦
èªã¿è¾¼ã¿æã¯CSV.foreach, æ¸ãè¾¼ã¿æã¯CSV.openã§è¡ãã®ãè¯ãããã§ãã ãªããèªã¿è¾¼ã¿æã®'converters'ãªãã·ã§ã³ã¯ã以ä¸ã®ä¾ã§ã¯åºã¦ãã¾ããããCSV.parseã ãã§ãªããCSV.foreachã§ã使ç¨å¯è½ãªããã§ãã ãã¨ãæ¹è¡ã³ã¼ãã®ä¸è¦ãªå¤æãé¿ããããâ¦
éçºä¸ã®ã½ã¼ã¹ã³ã¼ãã¯ãã³ã³ããå ã®ãã¡ã¤ã«ã·ã¹ãã ã«ç½®ãã®ã§ã¯ãªãããã¹ãã·ã¹ãã ã®ãã£ã¬ã¯ããªã§è¡ãã®ãé常ã ããã§ãã éçºä¸ã¯ããããªã¥ã¼ã ãã¦ã³ãã£ã³ã°ãã¨ããæ¹æ³ãç¨ãã¦ããã®ãã¡ã¤ã«ãã³ã³ããå ã®ç¹å®ãã£ã¬ã¯ããªã«åæ ããã¦å®â¦
Nokogiriã¯ãRubyã§XMLææ¸(å«ãHTML)ã解æã»ç·¨éã§ããã©ã¤ãã©ãªã§ããã¦ã§ãããå ¥æããææ¸ãããå¿ è¦ãªããã¹ããæ½åºã»å å·¥ããéã«å¨åãçºæ®ãã¾ãã åºæ¬çãªä½¿ãæ¹ãã¾ã¨ãã¦ç¥ããããªã£ãã®ã§ãChatGPT ã«è©³ããèãã¦ã¿ã¾ããã Rubyã®Nokogiâ¦
5è¡æ¸ãã ãã§Webãµã¼ãã¼ãåºæ¥ã¾ãã 'Ruby on Rails'ã®å¦ç¿ããããã¨ãããã¾ãããæ£ç´ããããéãã¦ã1åæ¬ãèªã¿çµããé ã«ã¯å人ç¨éã§ã¢ããªã±ã¼ã·ã§ã³ãä½ãæ°åã¯å¤±ãã¦ãã¾ããã åç´ãªãã®ããå¿ è¦ã«å¿ãã¦è¦æ¨¡ãæ¡å¤§ãã¦è¡ãæ¹ããå¦ç¿ã¯ã¹â¦
ææã¡ã®MacBook Airãå¤ããããç¹å®Gemãã¤ã³ã¹ãã¼ã«ã§ããªãã¨ãã£ããã¨ããã°ãã°èµ·ããã¾ãã Dockerã§Rubyã®éçºç°å¢ãä½ãã¨ãã©ããªæãã«ãªãã®ãã¤ã¡ã¼ã¸ãããã£ãã®ã§ãChatGPTã«ããããèãã¦ã¿ã¾ããã æè¿ã10å¹´ã»ã©åã«è²·ã£ãMacBook Aiâ¦
ã¾ã¨ãã¦ããããã£ãã®ã§ãèãã¦ã¿ã¾ããã ã¤ãã§ã«Kotlin, Javaã§ã®æä½ã確èªãã¾ããããRubyã¯ãã¯ããç°¡æ½ã§è¯ãã§ããã Rubyã§æååã«å¯¾ãã¦æ£è¦è¡¨ç¾ãç¨ããæä½ãããã¡ã½ããã«ã¤ãã¦æãã¦ãã ããã ããããã®æ段ã®ä½¿ãåãã®ç®å®ãããã°â¦
é·å¹´ç¥ãããã£ããã¨ã解決ãã¾ããã Androidä¸ã§åãLinuxã¨ãã¥ã¬ã¼ã¿ã®Termuxã使ã£ã¦ããã®ã§ãããããã§å¤ãAndroid端æ«ãWebãµã¼ãã¼ã«ãã¦ãä»ã®ç«¯æ«ãããã¼ã¿ã«ã¢ã¯ã»ã¹ãããå¤æ´ãããã¨ãã£ããã¨ãåºæ¥ããã§ãã ifconfigã®ãããªã³ãã³ãâ¦
ããããã«ç¹å¾´ãããããã§ãã å¤æéãå«ããã¿ã¤ã ã¾ã¼ã³ã®åæ±ãã¯ãTimeãå¾æãªããã§ãã Dateã¯æ¥ä»ããDateTimeã¯æ¥æãæ±ãã¯ã©ã¹ã§ãããåãå·®ãè¨ç®ããããåå¾ãæ¯è¼ãããã¨ãã£ããã¨ã¯ãã¡ãã®æ¹ãå¾æãªããã§ããä¸æ¹ãã¿ã¤ã ã¾ã¼ã³ã®â¦
Ruby1.9ãããRubyã®ããã·ã¥ã¯é åºãä¿æãã¦ããããã§ãçµã¿è¾¼ã¿ã®sort_byãªã©ã®ã¡ã½ããã使ã£ã¦ã½ã¼ããã§ããããã§ãã ãã ãsort_byã®æ»ãå¤ã¯ãã¼ã¨å¤ã®ãã¢ã®é åãªã®ã§ãããã«.to_hãå¼ã³åºãå¿ è¦ãããã¾ãã rubyã®ããã·ã¥ã§ãkeyã®é åºãä¿â¦
Ruby, Sinatraã§ã®Webã¢ããªéçºãé常ã«æ¥½ãªã®ã«æ°ä»ããChatGPTã«ããããèãã¦ãã¾ããRuby on Railsã¯å¤§è¦æ¨¡ã§ãè¤ééãã¦ãå人ç¨éã§ä½ããä½ãæ°ã«ã¯å°åºãªããªãã£ãã®ã§ãã ä»åã¯ä¸»ã«ããã¡ã¤ã«ã®ç½®ãå ´æãªã©ããã¹ã®èªã¿æ¿ããè¡ãããã®ã¯viâ¦