class WolfTrans::Context::Database

Attributes

datum_index[R]
datum_name[R]
db_name[R]
field_index[R]
field_name[R]
type_index[R]
type_name[R]

Public Class Methods

from_data(db_name, type_index, type, datum_index, datum, field) click to toggle source
# 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) click to toggle source
# 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
new(db_name, type_index, type_name, datum_index, datum_name, field_index, field_name) click to toggle source
# 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

Public Instance Methods

eql?(other) click to toggle source
Calls superclass method WolfTrans::Context#eql?
# 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() click to toggle source
# File lib/wolftrans/context.rb, line 164
def hash
  [@db_name, @type_index, @datum_index, @field_index].hash
end
to_s() click to toggle source
# 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