Class: TreasureData::Table
Instance Attribute Summary collapse
-
#count ⇒ Object
readonly
Returns the value of attribute count.
-
#db_name ⇒ Object
(also: #database_name)
readonly
Returns the value of attribute db_name.
-
#estimated_storage_size ⇒ Object
readonly
Returns the value of attribute estimated_storage_size.
-
#primary_key ⇒ Object
readonly
Returns the value of attribute primary_key.
-
#primary_key_type ⇒ Object
readonly
Returns the value of attribute primary_key_type.
-
#schema ⇒ Object
readonly
Returns the value of attribute schema.
-
#table_name ⇒ Object
(also: #name)
readonly
Returns the value of attribute table_name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Attributes inherited from Model
Instance Method Summary collapse
- #created_at ⇒ Object
- #database ⇒ Object
- #database=(database) ⇒ Object
- #delete ⇒ Object
- #estimated_storage_size_string ⇒ Object
- #expire_days ⇒ Object
- #export(storage_type, opts = {}) ⇒ Object
- #identifier ⇒ Object
- #import(format, stream, size) ⇒ Object
-
#initialize(client, db_name, table_name, type, schema, count, created_at = nil, updated_at = nil, estimated_storage_size = nil, last_import = nil, last_log_timestamp = nil, expire_days = nil, primary_key = nil, primary_key_type = nil) ⇒ Table
constructor
A new instance of Table.
- #last_import ⇒ Object
- #last_log_timestamp ⇒ Object
-
#permission ⇒ Object
get the database’s permission as if they were the table’s.
- #tail(count, to = nil, from = nil) ⇒ Object
- #update_database! ⇒ Object
- #updated_at ⇒ Object
Constructor Details
#initialize(client, db_name, table_name, type, schema, count, created_at = nil, updated_at = nil, estimated_storage_size = nil, last_import = nil, last_log_timestamp = nil, expire_days = nil, primary_key = nil, primary_key_type = nil) ⇒ Table
Returns a new instance of Table.
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/td/client/model.rb', line 108 def initialize(client, db_name, table_name, type, schema, count, created_at=nil, updated_at=nil, estimated_storage_size=nil, last_import=nil, =nil, expire_days=nil, primary_key=nil, primary_key_type=nil) super(client) @database = nil @db_name = db_name @table_name = table_name @type = type @schema = schema @count = count @created_at = created_at @updated_at = updated_at @estimated_storage_size = estimated_storage_size @last_import = last_import @last_log_timestamp = @expire_days = expire_days @primary_key = primary_key @primary_key_type = primary_key_type end |
Instance Attribute Details
#count ⇒ Object (readonly)
Returns the value of attribute count.
126 127 128 |
# File 'lib/td/client/model.rb', line 126 def count @count end |
#db_name ⇒ Object (readonly) Also known as: database_name
Returns the value of attribute db_name.
126 127 128 |
# File 'lib/td/client/model.rb', line 126 def db_name @db_name end |
#estimated_storage_size ⇒ Object (readonly)
Returns the value of attribute estimated_storage_size.
126 127 128 |
# File 'lib/td/client/model.rb', line 126 def estimated_storage_size @estimated_storage_size end |
#primary_key ⇒ Object (readonly)
Returns the value of attribute primary_key.
126 127 128 |
# File 'lib/td/client/model.rb', line 126 def primary_key @primary_key end |
#primary_key_type ⇒ Object (readonly)
Returns the value of attribute primary_key_type.
126 127 128 |
# File 'lib/td/client/model.rb', line 126 def primary_key_type @primary_key_type end |
#schema ⇒ Object (readonly)
Returns the value of attribute schema.
126 127 128 |
# File 'lib/td/client/model.rb', line 126 def schema @schema end |
#table_name ⇒ Object (readonly) Also known as: name
Returns the value of attribute table_name.
126 127 128 |
# File 'lib/td/client/model.rb', line 126 def table_name @table_name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
126 127 128 |
# File 'lib/td/client/model.rb', line 126 def type @type end |
Instance Method Details
#created_at ⇒ Object
135 136 137 |
# File 'lib/td/client/model.rb', line 135 def created_at @created_at && !@created_at.empty? ? Time.parse(@created_at) : nil end |
#database ⇒ Object
155 156 157 158 |
# File 'lib/td/client/model.rb', line 155 def database update_database! unless @database @database end |
#database=(database) ⇒ Object
131 132 133 |
# File 'lib/td/client/model.rb', line 131 def database=(database) @database = database if database.instance_of?(Database) end |
#delete ⇒ Object
169 170 171 |
# File 'lib/td/client/model.rb', line 169 def delete @client.delete_table(@db_name, @table_name) end |
#estimated_storage_size_string ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 |
# File 'lib/td/client/model.rb', line 185 def estimated_storage_size_string if @estimated_storage_size <= 1024*1024 return "0.0 GB" elsif @estimated_storage_size <= 60*1024*1024 return "0.01 GB" elsif @estimated_storage_size <= 60*1024*1024*1024 "%.1f GB" % (@estimated_storage_size.to_f / (1024*1024*1024)) else "%d GB" % (@estimated_storage_size.to_f / (1024*1024*1024)).to_i end end |
#expire_days ⇒ Object
151 152 153 |
# File 'lib/td/client/model.rb', line 151 def expire_days @expire_days ? @expire_days.to_i : nil end |
#export(storage_type, opts = {}) ⇒ Object
181 182 183 |
# File 'lib/td/client/model.rb', line 181 def export(storage_type, opts={}) @client.export(@db_name, @table_name, storage_type, opts) end |
#identifier ⇒ Object
165 166 167 |
# File 'lib/td/client/model.rb', line 165 def identifier "#{@db_name}.#{@table_name}" end |
#import(format, stream, size) ⇒ Object
177 178 179 |
# File 'lib/td/client/model.rb', line 177 def import(format, stream, size) @client.import(@db_name, @table_name, format, stream, size) end |
#last_import ⇒ Object
143 144 145 |
# File 'lib/td/client/model.rb', line 143 def last_import @last_import && !@last_import.empty? ? Time.parse(@last_import) : nil end |
#last_log_timestamp ⇒ Object
147 148 149 |
# File 'lib/td/client/model.rb', line 147 def @last_log_timestamp && !@last_log_timestamp.empty? ? Time.parse(@last_log_timestamp) : nil end |
#permission ⇒ Object
get the database’s permission as if they were the table’s
161 162 163 |
# File 'lib/td/client/model.rb', line 161 def database. end |
#tail(count, to = nil, from = nil) ⇒ Object
173 174 175 |
# File 'lib/td/client/model.rb', line 173 def tail(count, to=nil, from=nil) @client.tail(@db_name, @table_name, count, to, from) end |
#update_database! ⇒ Object
197 198 199 |
# File 'lib/td/client/model.rb', line 197 def update_database! @database = @client.database(@db_name) end |
#updated_at ⇒ Object
139 140 141 |
# File 'lib/td/client/model.rb', line 139 def updated_at @updated_at && !@updated_at.empty? ? Time.parse(@updated_at) : nil end |