Module: Triplifier::Node::ClassMethods
- Defined in:
- lib/triplifier/node.rb
Instance Attribute Summary collapse
-
#prefixes ⇒ Object
readonly
Returns the value of attribute prefixes.
-
#subjects ⇒ Object
readonly
Returns the value of attribute subjects.
Instance Method Summary collapse
- #defines(&block) ⇒ Object
- #node(&block) ⇒ Object
- #prefix(ns, uri) ⇒ Object
- #resource(string = nil, &block) ⇒ Object
- #subject(predicate, object = nil, &block) ⇒ Object
- #uri(string) ⇒ Object
Instance Attribute Details
#prefixes ⇒ Object (readonly)
Returns the value of attribute prefixes.
107 108 109 |
# File 'lib/triplifier/node.rb', line 107 def prefixes @prefixes end |
#subjects ⇒ Object (readonly)
Returns the value of attribute subjects.
107 108 109 |
# File 'lib/triplifier/node.rb', line 107 def subjects @subjects end |
Instance Method Details
#defines(&block) ⇒ Object
131 132 133 134 135 136 137 138 |
# File 'lib/triplifier/node.rb', line 131 def defines(&block) @defines = [] if @defines.nil? return @defines unless block_given? klass = Class.new(Triplifier::SimpleNode) klass.eval(&block) @defines << klass klass end |
#node(&block) ⇒ Object
125 126 127 128 129 |
# File 'lib/triplifier/node.rb', line 125 def node(&block) klass = Class.new(Triplifier::SimpleNode) klass.eval(&block) klass end |
#prefix(ns, uri) ⇒ Object
120 121 122 123 |
# File 'lib/triplifier/node.rb', line 120 def prefix(ns, uri) @prefixes = {} if @prefixes.nil? @prefixes[ns] = uri.kind_of?(URI) ? uri : Triplifier::URI.new(uri) end |
#resource(string = nil, &block) ⇒ Object
109 110 111 112 |
# File 'lib/triplifier/node.rb', line 109 def resource(string = nil, &block) return @resource if string.nil? && !block_given? @resource = string.nil? ? block : string end |
#subject(predicate, object = nil, &block) ⇒ Object
114 115 116 117 118 |
# File 'lib/triplifier/node.rb', line 114 def subject(predicate, object = nil, &block) @subjects = {} if @subjects.nil? @subjects[predicate] = [] if @subjects[predicate].nil? @subjects[predicate] << (object.nil? ? block : object) end |
#uri(string) ⇒ Object
140 141 142 |
# File 'lib/triplifier/node.rb', line 140 def uri(string) Triplifier::URI.new string end |