class Audrey::Node::Array
¶ ↑
Audrey::Node::Array
Public Class Methods
new_object()
click to toggle source
# File lib/audrey.rb, line 1161 def self.new_object return([]) end
Public Instance Methods
[](idx)
click to toggle source
# File lib/audrey.rb, line 1172 def [](idx) read_check() row = @engine.row_by_array_index(@pk, idx) # if we got a hash if row return @db.object_from_row(row) # else return nil else return nil end end
[]=(key, child)
click to toggle source
# File lib/audrey.rb, line 1193 def []=(key, child) end
attach_to(arr)
click to toggle source
# File lib/audrey.rb, line 1303 def attach_to(arr) # hold on to original values orgs = arr.clone # audrey() def arr.audrey(p_node = nil) if p_node @audrey_node = p_node end # return return @audrey_node end # NOTE: There must be a simpler way to delegate all these hash methods # to @audrey_node # [] def arr.[](idx) return @audrey_node[idx] end # push def arr.push(val) return @audrey_node.push(val) end # each def arr.each() if block_given? @audrey_node.each do |k, v| yield k, v end else return @audrey_node.each end end # each_with_index def arr.each_with_index() @audrey_node.each_with_index do |el, idx| yield el, idx end end # length def arr.length() return @audrey_node.length end # any? def arr.any?() return @audrey_node.any? end # clear def arr.clear() return @audrey_node.clear() end # join def arr.join(sep) rv = [] @audrey_node.each do |el| rv.push el end return rv.join(sep) end # include? def arr.include?(val) return @audrey_node.include?(val) end # initial call to audrey object arr.audrey self # save child elements orgs.each do |v| arr.push v end end
each() { |obj| ... }
click to toggle source
# File lib/audrey.rb, line 1216 def each # $tm.hrm read_check() rv = nil # loop through rows @engine.array_each(@pk) do |row| obj = @db.object_from_row(row) if block_given? yield obj else rv ||= [] rv.push obj end end # return return rv end
each_with_index() { |el, idx| ... }
click to toggle source
# File lib/audrey.rb, line 1237 def each_with_index idx = 0 each do |el| yield el, idx idx += 1 end end
include?(val)
click to toggle source
# File lib/audrey.rb, line 1272 def include?(val) # $tm.hrm # if val has a audrey object if val.respond_to?('audrey') each do |object| if object.respond_to?('audrey') if val.audrey.pk == object.audrey.pk return true end end end else each do |object| if val === object return true end end end # didn't find it return false end
push(child)
click to toggle source
# File lib/audrey.rb, line 1203 def push(child) write_check() save_child child return child end
to_array()
click to toggle source
# File lib/audrey.rb, line 1253 def to_array rv = [] each do |el| rv.push el end return rv end