This document discusses Sinatra, a Ruby web framework. It provides an overview of Sinatra and demonstrates how to build a simple "Hello World" application. It then shows how to add Haml templating to create views and ActiveRecord to interact with a SQLite database. The examples show creating a model, controller actions to save and retrieve data from the database, and displaying it on a view. In summary, the document presents Sinatra as an easy way to build web applications in Ruby and demonstrates integrating templating and database functionality.
14. PATTERN MATCH
使ったもの
• 柔軟なswitch文
instanceList foreach {
_ match {
case ClassA => println(“This is ClassA”)
case ClassB if _.hasChild()
=> println(“This is ClassB having ching”)
case _ => println(“other class”)
}
}
(foreach要素を受ける)
(クラスでマッチング)
(さらに if で条件付き)
(デフォルト)
16. SYNTAX SUGAR
使ったもの
• 文字列 -> XML
val nodes:NodeSeq = XML loadString str
• XMLタグ取得
xml “tagName”
• XML要素取得
xml “@attrName”
nodes foreach { _ match { case ~ } }