Class: Termtter::Storage::DB
- Inherits:
-
Object
- Object
- Termtter::Storage::DB
- Includes:
- Singleton
- Defined in:
- lib/plugins/storage/DB.rb
Instance Attribute Summary collapse
-
#db ⇒ Object
readonly
Returns the value of attribute db.
Instance Method Summary collapse
- #create_table ⇒ Object
-
#initialize ⇒ DB
constructor
A new instance of DB.
Constructor Details
#initialize ⇒ DB
Returns a new instance of DB.
11 12 13 14 15 |
# File 'lib/plugins/storage/DB.rb', line 11 def initialize @db = SQLite3::Database.new(Termtter::CONF_DIR + '/storage.db') @db.type_translation = true create_table end |
Instance Attribute Details
#db ⇒ Object (readonly)
Returns the value of attribute db.
9 10 11 |
# File 'lib/plugins/storage/DB.rb', line 9 def db @db end |
Instance Method Details
#create_table ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/plugins/storage/DB.rb', line 17 def create_table sql ="CREATE TABLE IF NOT EXISTS user (\nid int NOT NULL,\nscreen_name text,\nPRIMARY KEY (id)\n);\nCREATE TABLE IF NOT EXISTS post (\npost_id int NOT NULL, -- twitter\u5074\u306Epost\u306Eid\ncreated_at int, -- \u65E5\u4ED8(Ruby\u3067UNIX\u6642\u9593\u306B\u5909\u63DB)\nin_reply_to_status_id int, -- \u3042\u3063\u305F\u307B\u3046\u304C\u3088\u3044\u3089\u3057\u3044\nin_reply_to_user_id int, -- \u3042\u3063\u305F\u307B\u3046\u304C\u3088\u3044\u3089\u3057\u3044\npost_text text,\nuser_id int NOT NULL,\nPRIMARY KEY (post_id)\n);\n SQL\n @db.execute_batch(sql)\nend\n" |