more parfait ripples
changes due to previous changes in parfait api
This commit is contained in:
@ -72,16 +72,16 @@ module Parfait
|
||||
string = string.to_s if string.is_a? Symbol
|
||||
word = Parfait::Word.new( string.length )
|
||||
string.codepoints.each_with_index do |code , index |
|
||||
word.set_char(index , code)
|
||||
word.set_char(index + 1 , code)
|
||||
end
|
||||
word
|
||||
end
|
||||
def self.new_list array
|
||||
list = List.new_object
|
||||
list.set_length array.length
|
||||
index = 0
|
||||
index = 1
|
||||
while index < array.length do
|
||||
list.set(index , array[index])
|
||||
list.set(index , array[index - 1])
|
||||
end
|
||||
list
|
||||
end
|
||||
@ -89,9 +89,9 @@ module Parfait
|
||||
Word.class_eval do
|
||||
def to_s
|
||||
string = ""
|
||||
index = 0
|
||||
while( index < self.length)
|
||||
string[index] = get_char(index).chr
|
||||
index = 1
|
||||
while( index <= self.length)
|
||||
string[index - 1] = get_char(index).chr
|
||||
index = index + 1
|
||||
end
|
||||
string
|
||||
|
@ -26,9 +26,9 @@ module Parfait
|
||||
# set the names of the instance variables in one go
|
||||
# used while booting the classes. At runtime the list would grow dynamically
|
||||
def set_names list
|
||||
self.set_length list.length
|
||||
self.set_length list.get_length
|
||||
index = 0
|
||||
while index < list.length do
|
||||
while index < list.get_length do
|
||||
list.set(index , array.get(index))
|
||||
end
|
||||
end
|
||||
|
@ -79,7 +79,7 @@ module Parfait
|
||||
end
|
||||
|
||||
def grow_to(len)
|
||||
raise "Only positive lenths, #{len}" if len <= 0
|
||||
raise "Only positive lenths, #{len}" if len < 0
|
||||
old_length = self.get_length
|
||||
return if old_length >= len
|
||||
internal_object_grow(len + 1)
|
||||
|
@ -37,7 +37,7 @@ module Parfait
|
||||
|
||||
def get_layout()
|
||||
puts "ME #{self.class}"
|
||||
return internal_object_get(LAYOUT)
|
||||
return internal_object_get(LAYOUT_INDEX)
|
||||
end
|
||||
|
||||
# class stores the "latest" layout for instances, ie the layout a new object will
|
||||
|
@ -37,6 +37,7 @@ module Parfait
|
||||
counter = self.length()
|
||||
return if counter >= len
|
||||
internal_object_grow( len + 1)
|
||||
counter = counter + 1
|
||||
while( counter < len)
|
||||
set_char( counter , fill_char)
|
||||
counter = counter + 1
|
||||
@ -57,7 +58,8 @@ module Parfait
|
||||
def range_correct_index at
|
||||
index = at
|
||||
index = self.length + at if at < 0
|
||||
raise "index out of bounds #{at} > #{self.length}" if (index < 0) or (index > self.length)
|
||||
raise "index must be positive , not #{at}" if (index <= 0)
|
||||
raise "index too large #{at} > #{self.length}" if (index > self.length)
|
||||
return index
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user