module Ontopia::Topicmaps
Constants
- DEFAULT_BASE
- DEFAULT_JARS
- VERSION
Attributes
base[R]
Public Class Methods
base=(base)
click to toggle source
# File lib/ontopia/topicmaps.rb, line 82 def base=(base) setup_classpath(base) end
count(file, *args)
click to toggle source
# File lib/ontopia/topicmaps.rb, line 66 def count(file, *args) file(file).count(*args) end
default_stringifier()
click to toggle source
# File lib/ontopia/topicmaps.rb, line 50 def default_stringifier @default_stringifier ||= name_stringifier end
default_stringifier=(str)
click to toggle source
# File lib/ontopia/topicmaps.rb, line 46 def default_stringifier=(str) @default_stringifier = stringifier(str) end
file(file)
click to toggle source
# File lib/ontopia/topicmaps.rb, line 62 def file(file) Topicmap.new(file) end
query(file, *args, &block)
click to toggle source
# File lib/ontopia/topicmaps.rb, line 70 def query(file, *args, &block) file(file).query(*args, &block) end
query_maps(file, *args)
click to toggle source
# File lib/ontopia/topicmaps.rb, line 74 def query_maps(file, *args) file(file).query_maps(*args) end
setup_classpath(base = nil, jars = nil)
click to toggle source
# File lib/ontopia/topicmaps.rb, line 86 def setup_classpath(base = nil, jars = nil) if @base return unless base raise "#{self}: $CLASSPATH already set up: #{@base}" end @base = base ||= DEFAULT_BASE Array(jars || DEFAULT_JARS).join(':').split(':').each { |jar| (path = Dir[File.join(base, 'lib', "#{jar}.jar")].sort.last) ? $CLASSPATH << path : raise("JAR not found: #{jar} (#{base})") } init.each { |klass, (modules, block)| klass.send :include, Packages, *modules.map { |m| const_get(m) } klass.class_eval(&block) if block }.clear end
stringifier(str)
click to toggle source
# File lib/ontopia/topicmaps.rb, line 54 def stringifier(str) case str when self::StringifierIF then str.method(:to_string) when Symbol then send("#{str}_stringifier") else str end end
topics(file, *args)
click to toggle source
# File lib/ontopia/topicmaps.rb, line 78 def topics(file, *args) file(file).topics(*args) end
Protected Class Methods
define_stringifier(name) { || ... }
click to toggle source
# File lib/ontopia/topicmaps.rb, line 111 def define_stringifier(name) define_singleton_method(attr = "#{name}_stringifier") { singleton_class.send(:attr_reader, attr) instance_variable_set("@#{attr}", stringifier(yield)) } end
init(klass = nil, *modules, &block)
click to toggle source
# File lib/ontopia/topicmaps.rb, line 107 def init(klass = nil, *modules, &block) klass ? Topicmaps.init[klass] = [modules, block] : @init end
register_stringifier(klass, name) { || ... }
click to toggle source
# File lib/ontopia/topicmaps.rb, line 118 def register_stringifier(klass, name) init(klass, :StringifierIF) { Topicmaps.define_stringifier(name) { new } yield if block_given? } end