Class: WolfTrans::Context::Database
- Inherits:
-
WolfTrans::Context
- Object
- WolfTrans::Context
- WolfTrans::Context::Database
- Defined in:
- lib/wolftrans/context.rb
Instance Attribute Summary collapse
-
#datum_index ⇒ Object
readonly
Returns the value of attribute datum_index.
-
#datum_name ⇒ Object
readonly
Returns the value of attribute datum_name.
-
#db_name ⇒ Object
readonly
Returns the value of attribute db_name.
-
#field_index ⇒ Object
readonly
Returns the value of attribute field_index.
-
#field_name ⇒ Object
readonly
Returns the value of attribute field_name.
-
#type_index ⇒ Object
readonly
Returns the value of attribute type_index.
-
#type_name ⇒ Object
readonly
Returns the value of attribute type_name.
Class Method Summary collapse
- .from_data(db_name, type_index, type, datum_index, datum, field) ⇒ Object
- .from_string(path) ⇒ Object
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(db_name, type_index, type_name, datum_index, datum_name, field_index, field_name) ⇒ Database
constructor
A new instance of Database.
- #to_s ⇒ Object
Constructor Details
#initialize(db_name, type_index, type_name, datum_index, datum_name, field_index, field_name) ⇒ Database
Returns a new instance of Database.
146 147 148 149 150 151 152 153 154 |
# File 'lib/wolftrans/context.rb', line 146 def initialize(db_name, type_index, type_name, datum_index, datum_name, field_index, field_name) @db_name = db_name @type_index = type_index @type_name = Util.full_strip(type_name) @datum_index = datum_index @datum_name = Util.full_strip(datum_name) @field_index = field_index @field_name = Util.full_strip(field_name) end |
Instance Attribute Details
#datum_index ⇒ Object (readonly)
Returns the value of attribute datum_index.
141 142 143 |
# File 'lib/wolftrans/context.rb', line 141 def datum_index @datum_index end |
#datum_name ⇒ Object (readonly)
Returns the value of attribute datum_name.
142 143 144 |
# File 'lib/wolftrans/context.rb', line 142 def datum_name @datum_name end |
#db_name ⇒ Object (readonly)
Returns the value of attribute db_name.
138 139 140 |
# File 'lib/wolftrans/context.rb', line 138 def db_name @db_name end |
#field_index ⇒ Object (readonly)
Returns the value of attribute field_index.
143 144 145 |
# File 'lib/wolftrans/context.rb', line 143 def field_index @field_index end |
#field_name ⇒ Object (readonly)
Returns the value of attribute field_name.
144 145 146 |
# File 'lib/wolftrans/context.rb', line 144 def field_name @field_name end |
#type_index ⇒ Object (readonly)
Returns the value of attribute type_index.
139 140 141 |
# File 'lib/wolftrans/context.rb', line 139 def type_index @type_index end |
#type_name ⇒ Object (readonly)
Returns the value of attribute type_name.
140 141 142 |
# File 'lib/wolftrans/context.rb', line 140 def type_name @type_name end |
Class Method Details
.from_data(db_name, type_index, type, datum_index, datum, field) ⇒ Object
172 173 174 |
# File 'lib/wolftrans/context.rb', line 172 def self.from_data(db_name, type_index, type, datum_index, datum, field) Database.new(db_name, type_index, type.name, datum_index, datum.name, field.index, field.name) end |
.from_string(path) ⇒ Object
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 |
# File 'lib/wolftrans/context.rb', line 176 def self.from_string(path) if path.size != 4 raise "invalid path specified for DB context line" end indices = Array.new(3) path.each_with_index do |str, i| next if i == 0 str.match(/^\[\d+\]/) do |m| indices[i-1] = m.to_s[1..-2].to_i end str.sub!(/^\[\d+\]/, '') end Database.new(path[0], indices[0], path[1], indices[1], path[2], indices[2], path[3]) end |
Instance Method Details
#eql?(other) ⇒ Boolean
156 157 158 159 160 161 162 |
# File 'lib/wolftrans/context.rb', line 156 def eql?(other) super && @db_name == db_name && @type_index == other.type_index && @datum_index == other.datum_index && @field_index == other.field_index end |
#hash ⇒ Object
164 165 166 |
# File 'lib/wolftrans/context.rb', line 164 def hash [@db_name, @type_index, @datum_index, @field_index].hash end |
#to_s ⇒ Object
168 169 170 |
# File 'lib/wolftrans/context.rb', line 168 def to_s "DB:#{@db_name}/[#{@type_index}]#{@type_name}/[#{@datum_index}]#{@datum_name}/[#{@field_index}]#{@field_name}" end |