Class: ObjDS::Origin
- Inherits:
-
Object
- Object
- ObjDS::Origin
- Defined in:
- lib/objds.rb
Instance Method Summary collapse
- #create_table(name) ⇒ Object
- #get_all_from_table(table) ⇒ Object
- #get_attribute_from_table(table, attribute) ⇒ Object
-
#initialize ⇒ Origin
constructor
A new instance of Origin.
- #set_attribute_in_table(table, attribute, value) ⇒ Object
- #tables ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Origin
Returns a new instance of Origin.
7 8 9 10 |
# File 'lib/objds.rb', line 7 def initialize @tables = {} @table_list = [] end |
Instance Method Details
#create_table(name) ⇒ Object
12 13 14 15 16 17 18 19 |
# File 'lib/objds.rb', line 12 def create_table name unless @tables[name] @tables[name] = {} @table_list.push(name) else raise ObjDSError, "Table already exists" end end |
#get_all_from_table(table) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/objds.rb', line 45 def get_all_from_table table unless @tables[table] raise ObjDSError, "Table does not exist" else return @tables[table] end end |
#get_attribute_from_table(table, attribute) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/objds.rb', line 33 def get_attribute_from_table table, attribute begin unless @tables[table][attribute] raise ObjDSError, "Attribute does not exist" else return @tables[table][attribute] end rescue NoMethodError raise ObjDSError, "Table does not exist" end end |
#set_attribute_in_table(table, attribute, value) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/objds.rb', line 21 def set_attribute_in_table table, attribute, value begin unless @tables[table][attribute] @tables[table][attribute] = value else raise ObjDSError, "Attribute already exists" end rescue NoMethodError raise ObjDSError, "Table does not exist" end end |
#tables ⇒ Object
58 59 60 |
# File 'lib/objds.rb', line 58 def tables @table_list end |
#to_s ⇒ Object
53 54 55 56 |
# File 'lib/objds.rb', line 53 def to_s hex_mem_address = "#<ObjDS::Origin:0x" << self.object_id.to_s(16) << ">" return hex_mem_address end |