class Hypostasis::Tuple
Public Class Methods
new(*tuple)
click to toggle source
# File lib/hypostasis/tuple.rb, line 2 def initialize(*tuple) @tuple = tuple.to_a.flatten raise Hypostasis::Errors::InvalidTuple if @tuple.empty? self end
unpack(tuple_string)
click to toggle source
# File lib/hypostasis/tuple.rb, line 47 def self.unpack(tuple_string) Hypostasis::Tuple.new(FDB::Tuple.unpack(tuple_string)) end
Public Instance Methods
append(*extension)
click to toggle source
# File lib/hypostasis/tuple.rb, line 22 def append(*extension) return self if extension.empty? appended_tuple = @tuple + extension.to_a Hypostasis::Tuple.new(appended_tuple) end
prepend(*prefix)
click to toggle source
# File lib/hypostasis/tuple.rb, line 16 def prepend(*prefix) return self if prefix.empty? prepended_tuple = prefix.to_a + @tuple Hypostasis::Tuple.new(prepended_tuple) end
to_a()
click to toggle source
# File lib/hypostasis/tuple.rb, line 8 def to_a @tuple end
to_range()
click to toggle source
# File lib/hypostasis/tuple.rb, line 43 def to_range FDB::Tuple.range(@tuple) end
to_s()
click to toggle source
# File lib/hypostasis/tuple.rb, line 12 def to_s @tuple_str ||= FDB::Tuple.pack(@tuple) end
trim(count = 0)
click to toggle source
# File lib/hypostasis/tuple.rb, line 28 def trim(count = 0) count = count.to_i raise Hypostasis::Errors::TupleExhausted if count.abs > @tuple.size - 1 trimmed_tuple = @tuple if count > 0 trimmed_tuple.pop(count.abs) Hypostasis::Tuple.new(trimmed_tuple) elsif count < 0 trimmed_tuple.shift(count.abs) Hypostasis::Tuple.new(trimmed_tuple) else self end end