class RoadForest::Graph::FocusList

Attributes

base_node[RW]
root_url[RW]

Public Instance Methods

<<(value)
Alias for: append
append(value) click to toggle source
# File lib/roadforest/graph/focus-list.rb, line 22
def append(value)
  value = case value
    when nil         then RDF.nil
    when RDF::Value  then value
    when Array       then RDF::List.new(nil, graph, value)
    else value
  end

  if empty?
    new_subject = subject
    #graph.insert([new_subject, RDF.type, RDF.List])
  else
    old_subject, new_subject = last_subject, RDF::Node.new
    graph.delete([old_subject, RDF.rest, RDF.nil])
    graph.insert([old_subject, RDF.rest, new_subject])
  end

  graph.insert([new_subject, RDF.first, value.is_a?(RDF::List) ? value.subject : value])
  graph.insert([new_subject, RDF.rest, RDF.nil])

  self
end
Also aliased as: <<
append_node(subject=nil) { |node| ... } click to toggle source
# File lib/roadforest/graph/focus-list.rb, line 46
def append_node(subject=nil)
  if empty? and self.subject == RDF.nil
    raise "Attempted to append #{subject} to an empty list (remove the list and replace it)"
  end

  base_node.create_node(subject) do |node|
    append(node.subject)
    yield node if block_given?
  end
end
car()
Alias for: first
each() { |unwrap_value| ... } click to toggle source
Calls superclass method
# File lib/roadforest/graph/focus-list.rb, line 15
def each
  return to_enum unless block_given?
  super do |value|
    yield base_node.unwrap_value(value)
  end
end
first() click to toggle source
# File lib/roadforest/graph/focus-list.rb, line 11
def first
  at(0)
end
Also aliased as: car